返回信息流好奇,用的python3.4,
代码是:driver.find_element_by_id("account"),死活报下面错~~求大神支招。。。
F:\program\python\python.exe F:/自动化测试相关/qiyun/pytestfirttest.py
Traceback (most recent call last):
File "F:/自动化测试相关/qiyun/pytestfirttest.py", line 30, in <module>
e=driver.find_element_by_id("account")
File "F:\program\python\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 "F:\program\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 745, in find_element
{'using': by, 'value': value})['value']
File "F:\program\python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "F:\program\python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"account"}
(Session info: chrome=51.0.2704.106)
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64)
Process finished with exit code 1
这是一条镜像帖。来源:北邮人论坛 / python / #15875同步于 2016/9/8
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖
有了解python+selenium的大神吗?我这个定位怎么就不成功呢?
bbjj
2016/9/8镜像同步6 回复
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
也可以用exception handling来处理,如果没有找到报错就继续等。不过我这个是2.7啊。。
while 1
try:
e=driver.find_element_by_id("account")
break
except NoSuchElementException:
time.sleep(0.5)
应该是有 iframe吧,用driver.switch_to_frame(frame),然后再driver.find_element_by_id("account")