selenium webdriver chrome 116 停止工作

问题描述 投票:0回答:1

我安装了 webdriver-manager 4.0.0 和 Selenium 4.8.0。我正在使用下面的效果很好。

driver = webdriver.Chrome(service=Service(ChromeDriverManager(version="114.0.5735.90").install()), options=Options())

我的组织已升级到 Chrome 16,现在上述内容不再有效。据我所知,selenium 4.11.2 不再需要 webdriver 管理器,因为 selenium 管理器会自动处理驱动程序和浏览器本身。所以我升级到了selenium 4.11.2。

我试过这个:

driver = webdriver.Chrome()

还有这个:

service = Service()
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)

这两个都是我在网上找到的解决方案,解决了大多数人的问题,但没有解决我的问题。

我将在下面的控制台中发布部分错误日志:

E           selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: G:\some_path\venv\lib\site-packages\selenium\webdriver\common\window
s\selenium-manager.exe --browser chrome --output json.
E           {'code': 65, 'message': 'error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json): error tr
ying to connect: tcp connect error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection faile
d because connected host has failed to respond. (os error 10060)', 'driver_path': '', 'browser_path': ''}
 
 
E           selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

有人可以帮我吗?该问题与我的组织安全/代理设置有关还是我忽略了其他内容?

提前致谢

google-chrome selenium-webdriver webdriver driver
1个回答
0
投票

我认为 Service() 需要一个下载版本的 chromedriver 的路径。

您可以从此 link 1(版本 114 或更早版本)或此 link 2(版本 115 或更高版本)下载 chromedriver,然后将 Service 中的路径替换为 chromedriver 的实际路径(将其放在某处,然后复制它的路径并将其粘贴到 Service()) 中

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

# Service(path_to_chromedriver_executable)
service = Service('C:\\Users\\akram\\Desktop\\Work\\chromedriver-win64\\chromedriver.exe')
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)

url = "URL_TO_SCRAP"
driver.get(url)
page = driver.page_source

Note:
如果chrome和chromedrive都更新就更好了。

© www.soinside.com 2019 - 2024. All rights reserved.