You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac系统下ChromeDriver权限错误及Selenium代码执行失败求助

解决Mac下Selenium ChromeDriver权限问题与弃用警告

问题分析

你遇到两个核心问题:

  • executable_path 参数已被Selenium弃用,需改用Service对象
  • ChromeDriver执行权限被拒绝(PermissionError: [Errno 13])

解决步骤

1. 修复ChromeDriver权限问题

在终端执行以下命令:

  • 给ChromeDriver添加可执行权限:
    chmod +x /Users/user/Desktop/it_projects/python-google-automation/src/chromedriver
    
  • 解除Mac系统的安全隔离(如果之前弹出“无法打开”提示):
    xattr -d com.apple.quarantine /Users/user/Desktop/it_projects/python-google-automation/src/chromedriver
    

如果仍有安全拦截提示,打开「系统设置」→「隐私与安全性」,找到对应ChromeDriver的拦截记录,点击「仍要打开」。

2. 更新代码解决弃用警告

原代码的executable_path参数已被弃用,需改用Service对象重构代码:

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

# 初始化Service对象指定ChromeDriver路径
chrome_service = Service('/Users/user/Desktop/it_projects/python-google-automation/src/chromedriver')
# 传入Service对象启动浏览器
browser = webdriver.Chrome(service=chrome_service)
browser.get('https://www.google.com')

内容的提问来源于stack exchange,提问作者Özgür Sahin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 07:06:21