参考两位大佬的文章:代码实现对selenium的驱动器WebDrive的配置_疏狂难除的博客-CSDN博客

selenium打开浏览器报错成功解决selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain...-CSDN博客

直接上报错:

driver = webdriver.Chrome(options=chrome_options, service=service)
	  File "/root/anaconda3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 47, in __init__
	    self.service.path = DriverFinder.get_path(self.service, self.options)
	  File "/root/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/driver_finder.py", line 44, in get_path
	    raise NoSuchDriverException(f"Unable to obtain {service.path} using Selenium Manager; {err}")
	selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain ../data/chromedriver using Selenium Manager; Message: Unsuccessful command executed: /root/anaconda3/lib/python3.7/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --output json.
	error sending request for url (https://chromedriver.storage.googleapis.com/LATEST_RELEASE_105): operation timed out
	; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

参考两位的文章后感觉报错原因是寻找路径失败或冲突的问题。

因为运行过程中导入了from selenium.webdriver.chrome.service import Service用来指定路径下驱动,导致处理异常。

解决办法:同类型原因导致的报错,直接删去driver =webdriver.Chrome(options=chrome_options, service=service)中的service参数即可。

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐