我最近把我的mac电脑升级到OS Catalina(v 10.15.3)。在这次升级之后,我无法使用硒启动chrome驱动程序。

当我运行selenium代码启动chrome浏览器时,我面临以下错误。

“chromedriver”无法打开,因为开发人员无法验证”。 “macOS无法验证此应用程序没有恶意软件。”

请帮帮我!


当前回答

The above answers were helpful. I would just add that if you're running Selenium from a development environment, in my case a Jupyter Notebook, and this is the issue, you're likely to see a PermissionError: [Errno 13] Permission denied error. There are other causes for this error, but it can be that macOS Catalina is blocking chromedriver from running for security reasons. Following the approaches above, I ran it from the command line and then was able to open it from Jupyter using driver = webdriver.Chrome('path/to/chromedriver).

其他回答

我找到的工作如下

打开终端 导航到chromedriver文件所在的路径 执行以下任意一个命令

命令1:xattr -d com.apple.quarantine <可执行文件名称>

例子

/usr/local/Caskroom/chromedriver 
$ xattr -d com.apple.quarantine chromedriver 

(or)

命令2:spctl——add——label 'Approved' <可执行文件名>

来源:https://docwhat.org/upgrading-to-catalina

注意:这只适用于执行上述命令的文件。如果下载了新的chromedriver,则必须在新下载的文件上再次执行该命令

这是一个许可问题…… 升级chrome后,这个错误显示,所以我遵循下面提到的步骤,它在我的系统工作。

系统设置 安全与隐私 进入“常规”选项卡 允许从以下地方下载应用程序: 选择App Store和已识别的开发商 单击锁进行更改。 输入系统密码 点击“无论如何打开”来确认你要打开或安装应用程序的意图。

我发现,如果你尝试过这个解决方案:

// Get the path to chromedriver, example: /usr/local/bin/chromedriver
which chromedriver 

// Change permissions
xattr -d com.apple.quarantine <path_to_chromedriver>

你的浏览器打开后又立即关闭,这可能是因为安装了错误的chromedriver版本。

寻找你的chrome版本启动chrome然后选择

Chrome > About Google Chrome

删除您当前的chromedriver,并在“关于谷歌chrome”中搜索与您的chrome版本匹配的chromedriver(例如:96.0.4664.110)。我用的是一台安装了Monterey操作系统的mac电脑

解决此错误的最简单方法,请遵循以下步骤。

导航到你的chrome驱动程序保存/下载的地方 右击并选择Open with 选择使用终端打开 允许或选择yes 您应该在终端屏幕上看到一条成功消息 返回打开你的chrome驱动程序或IDE并运行,你应该不会再得到错误了

现有的答案很好,而且很有效。

但是一个更简单的解决方案是打开终端并运行这个:

xattr -d com.apple.quarantine $(which chromedriver)