Appium app 页面元素刷新 driver.refresh() 报错,The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

kiki · March 07, 2023 · 3788 hits

问题:
在 appium 执行 app 自动化时发现,app 页面内容已刷新,但通过 driver.page_source 获取 DOM 发现 appium DOM 解析的节点内容并未更新,由此相通过刷新操作刷新页面元素,有 driver.refresh() 可刷新页面,但执行报错如下:The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

以上报错发现,我调试的页面是 native 页面,但 refresh 只适用于 webview h5 页面刷新
官网有相关说明,如下:

那我们该如果解决 native 页面元素刷新问题呢,又尝试着通过页面点击查看是否能触发页面元素获取更新,试验发现可以通过点击页面非功能元素来触发更新 appium DOM 元素

以上总结如下:
1、deiver.refresh(),应用于 app 时,只适用于 webview h5 页面刷新
2、当终端页面显示已更新,但 appium dom 元素未更新,可以通过点击非功能元素来触发 dom 元素更新(适用于 android)

No Reply at the moment.
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up