Appium 同一个 NATIVE_APP,跳转页面后提示:NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

一世繁华 · 2018年11月06日 · 最后由 一世繁华 回复于 2018年11月06日 · 1099 次阅读

我登录后,点击【个人中心】图标,进入个人中心页面后,发现获取不到页面元素,打印出的 page_source 是上一个页面的内容,但是 NATIVE_APP 只有一个,且没有 webview,这种问题怎么解决呢?

环境:appium1.9.1
语言:Python2.7

Error
Traceback (most recent call last):
File "E:\workspace\python2.7\lib\unittest\case.py", line 329, in run
testMethod()
File "F:\autotest\AutoTestDesk\TestCases\Ksh\yakDriver\homePage.py", line 38, in test1
driver.find_element_by_id('com.just.busdriver:id/iv_back')
File "F:\autotest\AutoTestDesk\selenium\webdriver\remote\webdriver.py", line 359, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "E:\workspace\python2.7\lib\site-packages\appium\webdriver\webdriver.py", line 222, in find_element
'value': value})['value']
File "F:\autotest\AutoTestDesk\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "E:\workspace\python2.7\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

共收到 1 条回复 时间 点赞

问题已解决,官方文档描述:
Appium 对自动化 Android 应用程序的旗舰支持是通过 UiAutomator2 驱动程序。该驱动程序利用 Google 的 UiAutomator2 技术来促进设备或仿真器的自动化。
较旧的基于 Android 的驱动程序包括:
该 UiAutomator 驱动程序
该 Selendroid 驱动程序

而 app 启动时默认使用的是 UiAutomator,所以需要改为 UiAutomator2

在启动设置里配置:
automationName: 'uiautomator2'

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