Appium appium IOS 真机踩坑分享 NoSuchElementError

xpcs · 2024年07月22日 · 最后由 kiki 回复于 2024年07月30日 · 5100 次阅读

selenium.common.exceptions.NoSuchElementException: Message:
An element could not be located on the page using the given search parameters.;
For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
NoSuchElementError: An element could not be located on the page using the given search parameters.

本来脚本好用,突然就不好用了,定位不到元素,解决了 2 小时左右
尝试加入等待时间未解决
通过 inspector 可成功定位到元素
查看 context,也只有 native
尝试了升级 appium-python-client 和 selenium 版本也未解决
重启手机、重启电脑,也未解决
最后打算,打印页面源码查看,结果加入这句,欸,就可以定位到了,服了,也不知道啥原因。。。
log.info(f"page_souce: {app_driver.page_source}")
但是,不加依旧定位不到

环境:
windows11
真机 13promax 16.6
appium 版本 2.11.1
tidevice 版本 0.12.10
appium-python-client 版本 2.11.1
selenium 版本 4.11.2

共收到 4 条回复 时间 点赞

你加个 sleep 可能也能找到。

xpcs #2 · 2024年07月22日 Author
恒温 回复

我都 sleep 800 秒了,不好使啊😂

是这样的,APP UI 自动化的坑很多,投入大,收益小

click 一个非功能元素刷新 DOM 结构元素试试呢

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册