出现错误“无法将返回值转换为WebElement”
Xcode版本:10.0 Appium服务器版本:1.9.1 / 1.13.0 Appium客户端版本:6.1.0 / 7.0.0 硒版本:3.9.1 / 3.14.0 iOS模拟器版本:11.4
尝试了以下不同版本: Appium Server版本:从1.7.2到1.14.2 beta Appium客户端版本:5.0.4至7.0.0 还尝试包括隐式等待和显式等待。没有运气:(
Appium记录客户端如下:
[RemoteTestNG] detected TestNG version 6.11.0
Jul 01, 2019 10:34:30 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
FAILED CONFIGURATION: @BeforeSuite setupDriver
org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {element-6066-11e4-a52e-4f735466cecf=2B000000-0000-0000-777A-000000000000, ELEMENT=2B000000-0000-0000-777A-000000000000}
Build info: version: '3.5.2', revision: '10229a9', time: '2017-08-21T17:29:55.15Z'
System info: host: 'Bindacharyas-MacBook-Pro.local', ip: 'fe80:0:0:0:c4b:5bdc:c1c1:72f2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '1.8.0_211'
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:421)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1)
at io.appium.java_client.FindsByAccessibilityId.findElementByAccessibilityId(FindsByAccessibilityId.java:31)
at com.noon.ui.tests.sanitySuites.TestIOSAnother.prepareIOSForAppium(TestIOSAnother.java:103)
at com.noon.ui.tests.sanitySuites.TestIOSAnother.setupDriver(TestIOSAnother.java:58)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:326)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:419)
... 25 more
以下几行代码:
capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6s Plus");
capabilities.setCapability("wdaStartupRetries", 5);
capabilities.setCapability("autoAcceptAlerts", true);
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("newCommandTimeout", 250);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.4");
capabilities.setCapability(MobileCapabilityType.APP, "/Users/bindacharyaj/Documents/Simulator/k12App-ios.app");
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.UDID, "777EA4A8-0C82-485D-8347-8EF3527B135A");
capabilities.setCapability("bundleId", "com.noonEdu.k12App");
capabilities.setCapability("updatedWDABundleId", "com.facebook.wda.lib");
capabilities.setCapability("wdaLocalPort", 8101);
driver = new IOSDriver<MobileElement>(url, capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println(driver.getContext());
driver.context("NATIVE_APP");
}
// 6
@Test(enabled = true)
public void myFirstTest() throws InterruptedException {
Thread.sleep(000);
System.out.println("Test Started");
((WebElement) driver.findElement(By.xpath("//XCUIElementTypeStaticText[@name='السعودية']"))).click();
System.out.println("Click -1");
Thread.sleep(2000);
Appium将启动该应用程序,但无法单击任何本机元素。 任何帮助,将不胜感激!
预先感谢... !!!!