Appium Java获取“ // XCUIElementTypeMenuItem [@ name ='Select All']”的NoSuchElementException

时间:2019-12-30 03:18:37

标签: java ios iphone appium

功能如下。

Capabilities { allowTouchIdEnroll: true, app: /App..., autoAcceptAlerts: false, automationName: XCUITest, browserName: , bundleId: com.test.testing, databaseEnabled: false, deviceName: iPhone 6, fullReset: false, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: false, newCommandTimeout: 500, noReset: true, platform: MAC, platformName: iOS, platformVersion: 12.2, takesScreenshot: true, udid: 96EF2ED4-EA89-, useNewWDA: true, version: , webStorageEnabled: false, xcodeConfigFile: /Users/abc/pqr}

我正在尝试的代码是...

 WebElement element = driver.findElement(By.id("MyElement"));
            element.click();
            if(element.getText().length() >= 0){
                element.click();
                Actions actions = new Actions(driver);
                actions.perform();
                Thread.sleep(1000);
                WebElement selector = driver.findElement(By.xpath("//XCUIElementTypeMenuItem[@name='Select All']"));
                selector.click();
                element.sendKeys(Keys.valueOf("DELETE"));
           }

StatckTrace:

*** Element info: {Using=xpath, value=//XCUIElementTypeMenuItem[@name='Select All']}
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
  at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
  at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
  at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
  at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
  at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
  at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
  at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
  at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:322)
  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 org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:424)
  at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:152)
  at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
  at io.appium.java_client.ios.IOSDriver.findElementByXPath(IOSDriver.java:1)
  at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
  at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:314)
  at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
  at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
  at io.appium.java_client.ios.IOSDriver.findElement(IOSDriver.java:1)
  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 test.ui.element.EventFiringDriver$2.invoke(EventFiringDriver.java:91)
  at io.appium.java_client.ios.$Proxy21.findElement(Unknown Source)
  at test.ui.element.EventFiringDriver.findElement(EventFiringDriver.java:178)
  at test.ui.element.Driver.findElement(Driver.java:100)

所以,我的问题是在某些TextInputBox中,此逻辑效果很好,但对于某些特定的TextInputBoxes却失败了。可能是什么原因?

0 个答案:

没有答案