Appium 返回的值无法转换为WebElement

Appium 返回的值无法转换为WebElement,appium,appium-ios,Appium,Appium Ios,我正在使用Appium进行iOS自动化测试,我发现了这个错误 返回的值无法转换为WebElement/*[@text='Search Results'] Appium Java客户端版本:6.0.0-BETA5 降级java客户端对我来说不是一个选项,因为我使用的是最新测试版的一些方法 try { MobileElement titleView = navigationBar.findElement(By.xpath("//*[@text='" + title + "']"));

我正在使用Appium进行iOS自动化测试,我发现了这个错误

返回的值无法转换为WebElement/*[@text='Search Results']

Appium Java客户端版本:6.0.0-BETA5

降级java客户端对我来说不是一个选项,因为我使用的是最新测试版的一些方法

try {
        MobileElement titleView = navigationBar.findElement(By.xpath("//*[@text='" + title + "']"));
        return titleView.isDisplayed();
    }
更新:

我在渐变中添加了硒元素,如下所示:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'io.appium:java-client:6.0.0-BETA5'
implementation 'org.seleniumhq.selenium:selenium-server:3.9.1'

implementation "com.google.code.gson:gson:2.8.2"
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

compileOnly 'org.projectlombok:lombok:1.16.20'
annotationProcessor 'org.projectlombok:lombok:1.16.20'

testImplementation 'junit:junit:4.12'
}
但是当运行测试时,我仍然会得到错误。这里的构建版本是3.11.0。那是硒吗?这里的正确方法是什么

    org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: //*[@text='Search Results']
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'USGPSNYCM212943.local', ip: 'fe80:0:0:0:462:ed8d:f2e4:f85d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_152-release'
Driver info: driver.version: unknown

您好,请使用以下依赖项:

  <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>6.0.0-BETA5</version>
        </dependency>
 <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.9.1</version>
        </dependency> 

木卫一
java客户端
6.0.0-BETA5
org.seleniumhq.selenium
硒服务器
3.9.1

这应该可以解决您的问题,即使我在使用不同的selenium服务器版本时也遇到了类似的问题。

我为这个问题挣扎了几天。我尝试了各种论坛上提到的所有解决方案,如升级或降级appium版本等。最后,通过在驱动程序对象上添加5秒的简单隐式等待,问题得到了解决。如果您面临此问题,请尝试一下。

如果现在有人看到此问题,那么WebElement搜索取决于您使用的驱动程序

如果使用AndroidDriver,则将泛型类型引用为 机器人驱动; 驱动程序=新的AndroidDriver(新的URL(“”),功能)

如果使用appiumDriver,则将泛型类型引用为 AppiumDriver司机; 驱动程序=新的AndroidDriver(新的URL(“”),功能)


希望有帮助

在所需的功能中添加以下附加功能,然后应该可以工作:

capability.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "60");
我在用

Appium-windows-1.13.0
java-client-5.0.0-BETA6
我已经更新到

Appium-windows-1.15.1
java-client-6.0.0-BETA4

它成功了

谢谢,我在格拉德尔该怎么做?我对此非常陌生更新了我上面的问题,请了解我做错了什么。Hi@Suraj,我也面临着与我使用上述依赖项相同的问题:org.seleniumhq.selenium selenium java 3.9.1,但得到了相同的错误。