Appium (求助) 使用 uiatomator 定位和 appium 定位了 id.但是 python 运行时候报错无法找到该元素

Zen广诺 · 2018年07月25日 · 最后由 Zen广诺 回复于 2018年07月27日 · 1829 次阅读

python 代码:
#coding=utf-8
import time
from appium import webdriver
desired_caps ={
'platformName':'Android',
'deviceName':'S9B4C17415007705',
'platformVersion': '7.0',
'appPackage': 'org.tripwiser.widgetone',
'appActivity': 'org.zywx.wbpalmstar.engine.LoadingActivity',
'unicodeKeyboard': True,
'noReset': True,
'resetKeyboard':True
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
time.sleep(2)
driver.find_element_by_id('uid').send_keys("yanfa")

报错:Traceback (most recent call last):
File "D:\python\code111\test001.py", line 17, in
driver.find_element_by_id('uid').send_keys("yanfa")
File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "D:\python\lib\site-packages\appium\webdriver\webdriver.py", line 221, in find_element
'value': value})['value']
File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
self.error_handler.check_response(response)
File "D:\python\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
File "D:\python\lib\site-packages\appium\webdriver\errorhandler.py", line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File "D:\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

共收到 1 条回复 时间 点赞

为 Android7.0 的一 bug,用其他手机测试 OK

Zen广诺 关闭了讨论 07月27日 14:14
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册