TA的每日心情 | 擦汗 2016-6-29 09:56 |
---|
签到天数: 25 天 连续签到: 1 天 [LV.4]测试营长
|
源码
# coding=utf-8
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get("http://www.baidu.com/")
driver.find_element_by_name("tj_login").click()
div = driver.find_element_by_class_name("tong-content").find_element_by_name("userName")
div.send_keys("username")
driver.find_element_by_name("password").send_keys("password")
time.sleep(2)
driver.find_element_by_id("TANGRAM__PSP_10__submit").click()
driver.quit()
错误信息
D:\python\python.exe E:/其他/UV/bdlg.py
Traceback (most recent call last):
File "E:/����/UV/bdlg.py", line 7, in <module>
div = driver.find_element_by_class_name("tong-content").find_element_by_name("userName")
File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 378, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 712, in find_element
{'using': by, 'value': value})['value']
File "D:\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "D:\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"class name","selector":"tong-content"}
Process finished with exit code 1
|
|