gpt4 book ai didi

Selenim driver for Chrome 116.x and Mac(用于Chrome 116.x和Mac的Selenim驱动程序)

转载 作者:bug小助手 更新时间:2023-10-25 17:42:40 24 4
gpt4 key购买 nike



I have been using Chrome Selenium in Phyton for almost two years and works great. When Chrome is updated I normally go to https://chromedriver.chromium.org/ download the right version, copy it in the path and everything continues working fine.

我在Phyton使用铬硒已经快两年了,效果很好。当Chrome更新时,我通常会去https://chromedriver.chromium.org/下载正确的版本,将其复制到路径中,一切都会继续正常运行。


Since, chrome version 115.x the downloaded file name has changed and instead of 'chromedriver' now is 'Google Chrome for Testing.app'. I have changed the name referenced in python including the path and the extension but when trying to call webdriver.Chrome I obtained this error message:

自Chrome 115.x版以来,下载的文件名已更改,而不是‘chromedrive’,现在是‘Google Chrome for Testing.app’。我已经更改了在python中引用的名称,包括路径和扩展名,但在尝试调用webdriver.Chrome时,我收到以下错误消息:


'Message: 'executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home'

‘Message:’可执行文件的权限可能错误。请参阅https://sites.google.com/a/chromium.org/chromedriver/home‘


This is the source code that has been working fine until the last chrome version:

这是在上一个Chrome版本之前一直运行良好的源代码:


    def __init__(self, seleniumDriver):
from selenium import webdriver

try:
self.driver = webdriver.Chrome('./../SeleniumDrivers/Google Chrome for Testing.app')
self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": """
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
})
"""
})
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
self.driver = webdriver.Chrome(options=options, executable_path=seleniumDriver)

self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": """
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
})
"""
})
self.driver.execute_cdp_cmd("Network.enable", {})
except Exception as e:
print(e)

I am trying to uses the driver corresponding the last chrome version I have 116.x but instead of executing the driver and start scraping I received the indicated error message.

我正在尝试使用与我有116.x的上一个Chrome版本对应的驱动程序,但我没有执行该驱动程序并开始抓取,而是收到了指示的错误消息。


Thanks a lot!

非常感谢!


更多回答

You need to run in a terminal: chmod +x /path/to/chromedriver

您需要在终端中运行:chmod+x/path/to/chromedrive

Thank you Gilles, I did it but still not working

谢谢你,Gilles,我做了,但还是不起作用

The new version is not a binary but an "app" and within the package there is a file in "/Contents/MacOS/Google Chrome for Testing" that is an "exe" terminal file. When executing it in the terminal chrome test opens fine but if I indicated that path in python program I receive the error "'Google Chrome for Testing' executable needs to be in PATH. Please see sites.google.com/a/chromium.org/chromedriver/home " as if the path could not be resolved

新版本不是一个二进制文件,而是一个“应用程序”,在包中有一个文件在“/Contents/MacOS/Google Chrome for Testing”,这是一个“exe”终端文件。当在终端中执行它时,chrome测试打开正常,但如果我在python程序中指示该路径,我会收到错误“'Google Chrome for Testing'可执行文件需要在PATH中。请参阅sites.google.com/a/chromium.org/chromedriver/home“,好像路径无法解析

Solved: problem is that now you are allowed to download the whole Chrome, not only the driver, so I got confused and download Chrome.zip instead the regular chromedriver.ex

解决:问题是现在你可以下载整个Chrome,而不仅仅是驱动程序,所以我搞糊涂了,下载了Chrome.Zip,而不是普通的chromedriver.ex

优秀答案推荐
更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com