首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用于安卓应用程序定位器的NoSuchElementError

用于安卓应用程序定位器的NoSuchElementError
EN

Stack Overflow用户
提问于 2022-09-04 12:59:34
回答 1查看 98关注 0票数 0

我使用Appium 1.22.3和webdriverIO5来实现安卓移动自动化,我试图单击的元素的DOM如下所示:

代码语言:javascript
运行
复制
<android.widget.Button content-desc="Sign in">

我使用了不同的定位器组合如下:

代码语言:javascript
运行
复制
await $('android.widget.Button');
driver.elementsByAccessibilityId('Sign in');
$('Sign in');
$('id=Sign in')
findElementByAccessibilityId("Sign in"); 
dr.findElementByAccessibilityId("Sign in")

但是,这些xpath都不起作用,我得到的错误如下:

代码语言:javascript
运行
复制
2022-09-04 12:35:01:866 - [HTTP] {"using":"class name","value":"android.widget.Button"}
2022-09-04 12:35:01:869 - [debug] [W3C (b124862d)] Calling AppiumDriver.findElement() with args: ["class name","android.widget.Button","b124862d-91b8-4b4a-9d50-bba5b9b912f4"]
2022-09-04 12:35:01:869 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
2022-09-04 12:35:01:869 - [debug] [BaseDriver] Waiting up to 0 ms for condition
2022-09-04 12:35:01:869 - [debug] [WD Proxy] Matched '/element' to command name 'findElement'
2022-09-04 12:35:01:869 - [debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8200/wd/hub/session/0900bfc4-1ae4-4c76-895d-3203dca78bcc/element] with body: {"strategy":"class name","selector":"android.widget.Button","context":"","multiple":false}
2022-09-04 12:35:02:441 - [WD Proxy] Got response with status 404: {"sessionId":"0900bfc4-1ae4-4c76-895d-3203dca78bcc","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:70)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:266)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:260)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.chann...
2022-09-04 12:35:02:441 - [debug] [W3C] Matched W3C error code 'no such element' to NoSuchElementError
2022-09-04 12:35:02:454 - [debug] [W3C (b124862d)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.

感谢您对如何在这里识别正确的定位器的帮助。

EN

回答 1

Stack Overflow用户

发布于 2022-09-04 13:54:06

谢谢。我能够使用let el = await $(‘//android.widget.Button@content=“Sign”’);终于成功了!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73599608

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档