如何获取适配Chrome 116.0.5845.110的ChromeDriver并解决Mac安全报错
问题解决:Mac下ChromeDriver被Gatekeeper拦截报错
问题描述
使用Java进行Selenium自动化测试,Chrome版本为116.0.5845.110,因未找到完全对应版本的ChromeDriver,使用了同大版本的116.0.5845.96版本驱动,运行时触发Mac系统报错:
“chromedriver” can’t be opened because Apple cannot check it for malicious software.The software need to be updated.Contact the developer for more information.
测试代码如下:
System.setProperty("webdriver.chrome.driver" , "/Users/user1/Desktop/browserdriversforAutomatedtesting/chromedriver"); WebDriver driver = new ChromeDriver();
解决方法
方法1:系统设置临时放行
- 打开「系统设置」→「隐私与安全性」
- 滚动到页面最下方,找到关于chromedriver的拦截提示,点击「仍要打开」
- 重新运行测试代码即可
方法2:命令行移除隔离属性
打开终端,执行以下命令(替换为你的chromedriver实际路径):
xattr -d com.apple.quarantine /Users/user1/Desktop/browserdriversforAutomatedtesting/chromedriver
执行完成后直接运行测试代码,不会再触发拦截
版本兼容性说明
Chrome 116.x及以后版本,ChromeDriver的小版本号差异(如5845.96和5845.110)不会影响兼容性,只要大版本号一致即可正常使用,无需严格匹配最后一段版本号
内容的提问来源于stack exchange,提问作者Rajeesha R
相关产品推荐
相关产品推荐

