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.


↙↙↙阅读原文可查看相关链接,并与作者交流