help+
1.<a id="LinkBtn_Life" href="javascript:__doPostBack('LinkBtn_Life','')">更多...</a>2.driver.find_element_by_id("LinkBtn_Life").click() 通过id 触发单击事件。会报如下错误,好奇怪!
*****************
raceback (most recent call last):
File "D:\张艳\test\python\Irhate\login.py", line 20, in <module>
driver.find_element_by_id("LinkBtn_Life").click()
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 282, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 784, in find_element
'value': value})['value']
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 249, in execute
self.error_handler.check_response(response)
File "C:\Users\IRH-PC\AppData\Local\Programs\Python\Python36\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:
定位不对么 别的定位方式也会报错么? 帮顶 1.看看你这id前面有没有frame框架,有,则转换一下switch_to_frame()。。。。
2.加个时间等待,time.sleep(2)...
3.看看是不是id,关闭页面,再打开查看元素的id有没有变化。。。。
页:
[1]