我正在使用appium执行自动化脚本,但发现了一些错误。你能帮我解决下面的错误吗?
File f = new File("D:/External Resource");
File aps = new File(f,"ApiDemos-debug.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 5X API 25");
cap.setCapability(MobileCapabilityType.APP, aps.getAbsolutePath());
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElementByXPath("//android.widget.TextView[@text='Views']").click();
Thread.sleep(3000);
TouchAction t = new TouchAction(driver);
t.tap(driver.findElementByXPath("//android.widget.TextView[@text='Expandable Lists']"));
Thread.sleep(3000);
driver.findElementByXPath("//android.widget.TextView[@text='1. Custom Adapter']").click();
t.press(driver.findElementByXPath("//android.widget.TextView[@text='People Names']"));
Thread.sleep(3000);
t.release().perform();
driver.findElementByXPath("");
driver.findElementByXPath("android:id/alertTitle").getText();
我使用的是最新版本
1. Selenium版本:Selenium-java-3.6.0
2 .. Appium Java客户端:java-client-5.0.3
org.openqa.selenium.WebDriverException:返回的值无法转换为WebElement:{ELEMENT = 1}
构建信息:版本:'未知',修订版:'未知',时间:'未知'
系统信息:主机:'PHO147',ip:'192.168.3.147',os.name:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'1.8.0_71 “
驱动程序信息:driver.version:AndroidDriver 在org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:417) at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62) at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) 在io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1) 在org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:509) at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:140) at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1) 在io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1) at gesture.testGest(gesture.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108) at org.testng.internal.Invoker.invokeMethod(Invoker.java:661) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) 在org.testng.TestRunner.privateRun(TestRunner.java:744) 在org.testng.TestRunner.run(TestRunner.java:602) 在org.testng.SuiteRunner.runTest(SuiteRunner.java:380) 在org.testng.SuiteRunner.run顺序(SuiteRunner.java:375) 在org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) 在org.testng.SuiteRunner.run(SuiteRunner.java:289) 在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301) 在org.testng.TestNG.runSuitesLocally(TestNG.java:1226) 在org.testng.TestNG.runSuites(TestNG.java:1144) 在org.testng.TestNG.run(TestNG.java:1115) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) 在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76) 引起:java.lang.ClassCastException:java.util.HashMap无法强制转换为org.openqa.selenium.WebElement 在org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:415)