#启动app时,需要一定时间进入引导页,所以必须设置等待时间,不然下面会一直报错定位不到元素 time.sleep(5)
driver.get_window_size() print driver.get_window_size()
time.sleep(5) #driver.background_app(5) #driver.launch_app() #print(driver.current_activity) a = driver.find_element_by_name("G") #print #driver.quit() 作者: qq245124928 时间: 2016-11-30 11:31
appium version:1.4.16.11作者: qq245124928 时间: 2016-11-30 11:32
报错:
C:\Python27\python.exe C:/text/apptest/appium1.py
{'platformVersion': '4.4.3', 'deviceName': 'HMB1AMBG', 'platformName': 'Android', 'appActivity': 'com.galanz.view.SplashActivity', 'appPackage': 'com.galanz.view'}
{u'width': 480, u'height': 854}
Traceback (most recent call last):
File "C:/text/apptest/appium1.py", line 34, in <module>
a = driver.find_element_by_name("G")
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 365, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
'value': value})['value']
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters. 作者: Miss_love 时间: 2016-11-30 13:27
An element could not be located on the page using the given search parameters.作者: Bugkiller 时间: 2016-11-30 13:34
沙发作者: lamecho 时间: 2017-3-17 13:45
a = driver.find_element_by_name("G")这句问题
尽量避免用这个方法去找元素(by name)
多去用find_element_by_id(),去看看你要找的这个G元素的id是什么!作者: quhuayin 时间: 2017-4-6 10:23
byname('G') 可能这个页面 有许多name 为G 这样定位不准确,有id 用id,或xpath