python菜鸟初学selenium+chromedrive,简单点击出错,请指教
源码:fromseleniumimportwebdriverimporttimeqinghuancun=webdriver.Chrome()#输入网址qinghuancu...
源码:
from selenium import webdriver
import time
qinghuancun = webdriver.Chrome()
#输入网址
qinghuancun.get('chrome://settings/clearBrowserData')
time.sleep(10)
tijiao = qinghuancun.find_element_by_id('#clearBrowsingDataConfirm')
tijiao.click()
报错:
D:\Python\Python36-32\test\simu\venv\Scripts\python.exe D:/Python/Python36-32/test/login.py
Traceback (most recent call last):
File "D:/Python/Python36-32/test/login.py", line 10, in <module>
tijiao = qinghuancun.find_element_by_id('#clearBrowsingDataConfirm')
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 360, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="#clearBrowsingDataConfirm"]"}
(Session info: chrome=75.0.3770.90) 展开
from selenium import webdriver
import time
qinghuancun = webdriver.Chrome()
#输入网址
qinghuancun.get('chrome://settings/clearBrowserData')
time.sleep(10)
tijiao = qinghuancun.find_element_by_id('#clearBrowsingDataConfirm')
tijiao.click()
报错:
D:\Python\Python36-32\test\simu\venv\Scripts\python.exe D:/Python/Python36-32/test/login.py
Traceback (most recent call last):
File "D:/Python/Python36-32/test/login.py", line 10, in <module>
tijiao = qinghuancun.find_element_by_id('#clearBrowsingDataConfirm')
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 360, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\Python\Python36-32\test\simu\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="#clearBrowsingDataConfirm"]"}
(Session info: chrome=75.0.3770.90) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询