运行结果:
raceback (most recent call last):
File "D:\Python27\Test\autotest\mail163.py", line 6, in <module>
driver.find_element_by_xpath("//form/div/div/div[2]/input").send_keys("username")
File "D:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 290, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "D:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 744, in find_element
{'using': by, 'value': value})['value']
File "D:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 233, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium-2.53.1-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//form/div/div/div[2]/input"}
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///c:/users/administrator/appdata/local/temp/tmphmt2c9/extensions/fxdriver@googlecode.com/components/driver-component.js:10770)
at FirefoxDriver.prototype.findElement (file:///c:/users/administrator/appdata/local/temp/tmphmt2c9/extensions/fxdriver@googlecode.com/components/driver-component.js:10779)
at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/administrator/appdata/local/temp/tmphmt2c9/extensions/fxdriver@googlecode.com/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///c:/users/administrator/appdata/local/temp/tmphmt2c9/extensions/fxdriver@googlecode.com/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///c:/users/administrator/appdata/local/temp/tmphmt2c9/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)