java-client: can't find element when use 5.0.0 beta1,wrong:"java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement cannot be cast to io.appium.java_client.MobileElement"
Description
when I use 5.0.0beta1 java-client,I can’t find any element.the wrong is:
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement cannot be cast to io.appium.java_client.MobileElement
Environment
- java client build version or git revision if you use some shapshot:5.0.0 beta1 from maven
- Appium server version or git revision if you use some shapshot:1.6.0 and 1.6.3
- Mobile platform/version under test:ios 10.2,xcode 8.2.1
- Real device or emulator/simulator:real
Details
public class Test {
private IOSDriver<MobileElement> driver = null;
@BeforeClass
public void beforeclass() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "IOS");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "111");
capabilities.setCapability(MobileCapabilityType.APP, "my app");
capabilities.setCapability(MobileCapabilityType.UDID, "my udid");
try {
driver = new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
@Test
public void element() throws InterruptedException {
Thread.sleep(10000);
MobileElement element = (MobileElement) driver.findElement(By.className("XCUIElementTypeScrollView"));
element.getSize();
Thread.sleep(10000);
}
@AfterClass(alwaysRun = true)
public void afterclass() {
driver.quit();
}
}
Ecxeption stacktraces
FAILED: element
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement cannot be cast to io.appium.java_client.MobileElement
at com.haimi.HMLibrary.keywords.swipeTest.element(swipeTest.java:52)
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:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
Link to Appium logs
[debug] [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/6B9292D7-5B44-488B-9D68-5D8B90899294/element] with body: {“using”:“class name”,“value”:“XCUIElementTypeScrollView”} [debug] [JSONWP Proxy] Got response with status 200: {“value”:{“ELEMENT”:“22FC9416-0EB1-47CB-A800-019C566EC450”,“type”:“XCUIElementTypeScrollView”,“label”:null},“sessionId”:“6B9292D7-5B44-488B-9D68-5D8B90899294”,“status”:0} [debug] [MJSONWP] Responding to client with driver.findElement() result: {“ELEMENT”:“22FC9416-0EB1-47CB-A800-019C566EC450”,“type”:“XCUIElementTypeScrollView”,“label”:null}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 25 (17 by maintainers)
Commits related to this issue
- Merge pull request #556 from TikhomirovSergey/master #552 FIX — committed to appium/java-client by TikhomirovSergey 7 years ago
@derunewige @SrinivasanTarget @saikrishna321 Ok. I can propose a PR. But there is some server side issue defenetely.
This issue got fixed in java-client-5.0.1.jar
He is working on it and will be proposing a PR soon 😃
On Wed 4 Jan, 2017, 8:48 PM Sai Krishna, notifications@github.com wrote: