java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to io.appium.java_client.MobileDriver
See original GitHub issueThe problem
I am getting below error message on line where i used “TouchAction action = new TouchAction((MobileDriver)driver);”
Please what should i do to remove below error.
ERROR MESSAGE:
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to io.appium.java_client.MobileDriver at com.qa.DragAndDrop.DragandDrop.getDesireCapabilities(DragandDrop.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Environment
- Appium version : 1.6.5 this i am using from command line.
- Last Appium version that did not exhibit the issue (if applicable): v1.1.0-beta.4 (this is UI version) {This is with UI}
- Desktop OS/version used to run Appium: Window 7 proffesional / 64 bit
- Node.js version (unless using Appium.app|exe): Node.js 6.11.0 (x64) and npm
- Mobile platform/version under test: 4.2.1
- Real device or emulator/simulator: Real Device
- Appium CLI or Appium.app|exe: Appium CLI
Code To Reproduce Issue :
package com.qa.DragAndDrop; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver;
import io.appium.java_client.AppiumDriver; import io.appium.java_client.MobileDriver; import io.appium.java_client.TouchAction; import io.appium.java_client.remote.MobileCapabilityType;
public class DragandDrop { //WebDriver driver; //AppiumDriver<AppiumWebElement> driver; RemoteWebDriver driver;
String device = "Android";
String devicename = "0123456789ABCDEF";
String platformversion = "4.2.1";
String platformname = "Android";
@Test
public void getDesireCapabilities() throws MalformedURLException, InterruptedException
{
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("device", device);
/*cap.setCapability(MobileCapabilityType.DEVICE_NAME, devicename);
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, platformname);
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, platformversion);*/
cap.setCapability("deviceName", devicename);
cap.setCapability("platformName", platformname);
cap.setCapability("platformVersion", platformversion);
cap.setCapability("browserName", "");
cap.setCapability("appPackage", "com.mobeta.android.demodslv");
cap.setCapability("appActivity", "com.mobeta.android.demodslv.Launcher");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "100");
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"),cap);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.xpath("//android.widget.TextView[@text='Basic usage playground']")).click();
WebElement source = driver.findElement(By.xpath("//android.widget.TextView[@text='Chick Corea']"));
WebElement destination = driver.findElement(By.xpath("//android.widget.TextView[@text='Wayne Shorter']"));
TouchAction action = new TouchAction((MobileDriver)driver);
System.out.println("Dragging item");
action.longPress(source).moveTo(destination).release().perform();
System.out.println("Dragged Succssfully");
//driver.quit();
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:14
Top GitHub Comments
closing this issue, i got the solution.
You should post the solution for others