WebDriverException:未定义任何命令或响应编解码器。 Appium WebDriver无法找到UIButton

时间:2016-12-12 10:38:53

标签: java selenium-webdriver appium appium-ios

Appium WebDriver无法查找/定位视图元素(如UIButton),也无法单击该元素。我在Mac机器上使用Appium.app运行Appium服务器。

  • Mac OS:10.11.6
  • XCode:6.1
  • Appium:1.5.3(Ara)
  • iPhone 6,8.1模拟器
  • Java 1.8
  • Java-Client:4.1.2
  • 硒:3.0.1

iOS设置: BasicAdvancedSettings

Source Code:
public void setUp() {
    try {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "iPhone 6");
        driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}

public void startTest() {
    try {
        WebDriverWait waitObj = new WebDriverWait(driver, 2 * 60);
        WebElement btnRegister = waitObj.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]"))); // Exception
        btnRegister.click();
        //driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[1]")).click(); // Same exception here
        driver.navigate().back();
        waitObj.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[2]"))).click();
        //driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAButton[2]")).click();
        driver.navigate().back();
    }catch (Exception e){
        e.printStackTrace();
    }
}
  

org.openqa.selenium.support.ui.ExpectedConditions findElement警告:   findElement抛出的WebDriverException(By.xpath:   // UIAApplication 1 / {UIAWindow {3}} / {UIAButton {3}})   org.openqa.selenium.WebDriverException:没有命令或响应编解码器   已定义。无法继续构建信息:版本:'3.0.1',   修订版:'1969d75',时间:'2016-10-18 09:49:13 -0700'系统信息:   主持人:'GMCSs-Mac-mini.local',ip:'192.168.1.24',os.name:'Mac OS X',   os.arch:'x86_64',os.version:'10 .11.6',java.version:'1.8.0_74'   驱动程序信息:driver.version:RemoteWebDriver at   org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:153)     在   org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)     at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)     在   org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368)     在   org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:473)     在org.openqa.selenium.By $ ByXPath.findElement(By.java:361)at at   org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)     在   org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)     在   org.openqa.selenium.support.ui.ExpectedConditions.access $ 000(ExpectedConditions.java:41)     在   org.openqa.selenium.support.ui.ExpectedConditions $ 7.适用(ExpectedConditions.java:181)     在   org.openqa.selenium.support.ui.ExpectedConditions $ 7.适用(ExpectedConditions.java:178)     在   org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:238)     在com.gmcs.appiumtest.TutorTest.startTest(TutorTest.java:37)at   com.gmcs.appiumtest.Main.main(Main.java:8)at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

1 个答案:

答案 0 :(得分:1)

您可以尝试将io.appium / java-client jar更新为4.0.0

我有类似的问题。我将java-client从3.0.1更改为4.0.0,问题解决了。