返回值无法转换为 WebElement

编程入门 行业动态 更新时间:2024-10-27 22:20:22
本文介绍了返回值无法转换为 WebElement的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用 Appium 进行 iOS 自动化测试,但出现此错误

I'm using Appium for iOS Automation testing and I'm getting this error

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

Returned value cannot be converted to WebElement //*[@text='Search Results']

Appium Java 客户端版本:6.0.0-BETA5

Appium Java client version: 6.0.0-BETA5

降级 Java 客户端不是我的选择,因为我使用的是最新测试版中的一些方法.

Downgrading java client is not an option for me as I'm using some methods from the latest beta version.

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

更新:

我像这样在我的 gradle 中添加了硒:

I added selenium in my gradle like this:

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.是硒吗?这里的正确方法是什么?

But when running tests, I still get the error. The build version here is 3.11.0. Is that Selenium? What is the right approach here?

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

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

This should solve your problem, even i faced similar issue when i used different selenium server version.

这篇关于返回值无法转换为 WebElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 19:15:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/919130.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   返回值   WebElement

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!