执行的时候一直提示找不到这个元素,报错:
Traceback (most recent call last):
File "D:\selenium_study\test.py", line 8, in <module>
driver.find_element_by_id("txtusername").send_keys("sa")
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 269, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
'value': value})['value']
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"txtusername"}
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///c:/users/zoumin/appdata/local/temp/tmpmlwwor/extensions/fxdriver@googlecode.com/components/driver-component.js:10770)
at FirefoxDriver.prototype.findElement (file:///c:/users/zoumin/appdata/local/temp/tmpmlwwor/extensions/fxdriver@googlecode.com/components/driver-component.js:10779)
at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/zoumin/appdata/local/temp/tmpmlwwor/extensions/fxdriver@googlecode.com/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///c:/users/zoumin/appdata/local/temp/tmpmlwwor/extensions/fxdriver@googlecode.com/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///c:/users/zoumin/appdata/local/temp/tmpmlwwor/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)