testing - 真实设备上的 Appium 测试用例无法识别他们应该点击的元素
问题描述
我为 react native 应用程序编写了一些测试,在这里和那里提供了一些 testID(正在使用 testProps,对 Android 和 iOS 来说非常好),并且测试在虚拟设备(iOS 模拟器和 Android 模拟器)上运行顺利。现在我已经从 react native 应用程序构建了一个 apk 文件和 ipa,如果我想在真实设备上运行 appium 测试,并且(直到现在)完美运行的 appium 测试,测试似乎找不到可访问性标签。我还使用 appium 检查器检查了页面,但似乎在 apk 文件中找不到提供的可访问性标签。日志也没有帮助,因为它只是说:
[MJSONWP (b824eb6b)] Calling AppiumDriver.findElements() with args:
["accessibilityid","nextbutton.button","b824eb6b-2100-4e76-bf55-4c1fc341555a"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name,
accessibility id, -android uiautomator [BaseDriver] Waiting up to 0 ms for condition [WD
Proxy] Matched '/elements' to command name 'findElements' [WD Proxy] Proxying [POST
/elements] to [POST http://localhost:8200/wd/hub/session/c4a35d0d-d5be-4849-
a3fc-13364f4fc77c/elements] with body: {"strategy":"accessibility
id","selector":"nextbutton.button","context":"","multiple":true} [WD Proxy] Got response
with status 200: {"sessionId":"c4a35d0d-d5be-4849-a3fc-13364f4fc77c","value":[]} [MJSONWP
(b824eb6b)] Responding to client with driver.findElements() result: [] [HTTP] <-- POST
/wd/hub/session/b824eb6b-2100-4e76-bf55-4c1fc341555a/elements 200 102 ms - 74 [HTTP]
[HTTP] --> POST /wd/hub/session/b824eb6b-2100-4e76-bf55-4c1fc341555a/elements [HTTP]
{"using":"accessibility id","value":"nextbutton.button"}
环境
Appium version: 1.15.1
Desktop OS/version used to run Appium: MacOS Catalina
Real device or emulator/simulator: Android 7, Galaxy S6 edge
#
其他人遇到过这个问题吗?
解决方案
id
以我的经验,通过or找到元素可以xpath
得到最好的结果。你确定你抓的是正确的accessibility_id
吗?
根据appium参考,accessibility_id
读取 UI 元素的唯一标识符。对于 XCUITest,它是元素的accessibility-id 属性。对于 Android,它是元素的 content-desc 属性。
推荐阅读
- swift - 使用 Swift 泛型调用非泛型库
- java - 如何在Java中删除某些已从玩家手中使用过的牌?
- api - 返回 csv 文件 - Deno
- typescript - tsconfig:重组文件夹以将兄弟姐妹变为子文件夹
- java - Spring boot & Java - HTTP 状态 404 错误又名白标签错误
- reactjs - 反应并将 jwt 令牌存储在本地存储中
- meshlab - 在 Meshlab 中设置测量单位
- python - 如果服务器未连接,防止 python 脚本停止
- asp.net-core - ASP.NET Core 3 MVC:如果找不到所需的视图,则提供默认视图
- c# - c#从json文件中搜索数据