|
#coding=UTF-8
'''
Created on 2015-7-6
@author: paomo
'''
from selenium import webdriver
MyBrowser=webdriver.Firefox()
MyBrowser.get("https://www.baidu.com/")
MyBrowser.find_element_by_xpath("/html/body/div[4]/div/div/div[3]/a[6]").click()
if __name__ == '__main__':
pass
报错信息:
Traceback (most recent call last):
File "E:\Users\aidupeng\workspace\test\test1.py", line 14, in <module>
MyBrowser.find_element_by_xpath("/html/body/div[4]/div/div/div[3]/a[6]").click()
File "C:\Python27\lib\site-packages\selenium-2.40.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 221, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Python27\lib\site-packages\selenium-2.40.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 681, in find_element
{'using': by, 'value': value})['value']
File "C:\Python27\lib\site-packages\selenium-2.40.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 164, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium-2.40.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: u'Unable to locate element: {"method":"xpath","selector":"/html/body/div[4]/div/div/div[3]/a[6]"}' ; Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///c:/users/aidupeng/appdata/local/temp/tmpjqsgdv/extensions/fxdriver@googlecode.com/components/driver_component.js:8904)
at FirefoxDriver.prototype.findElement (file:///c:/users/aidupeng/appdata/local/temp/tmpjqsgdv/extensions/fxdriver@googlecode.com/components/driver_component.js:8913)
at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/aidupeng/appdata/local/temp/tmpjqsgdv/extensions/fxdriver@googlecode.com/components/command_processor.js:10878)
at DelayedCommand.prototype.executeInternal_ (file:///c:/users/aidupeng/appdata/local/temp/tmpjqsgdv/extensions/fxdriver@googlecode.com/components/command_processor.js:10883)
at DelayedCommand.prototype.execute/< (file:///c:/users/aidupeng/appdata/local/temp/tmpjqsgdv/extensions/fxdriver@googlecode.com/components/command_processor.js:10825)
|
|