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

MacOS下Selenium+SeleniumWire启动Firefox报错:进程意外终止

MacOS下Selenium+SeleniumWire启动Firefox失败的排查方案

在MacOS Sonoma 14.2.1系统上使用Selenium结合SeleniumWire时,出现Firefox无法启动的问题,错误提示为Process unexpectedly closed with status signal。该功能原本运行正常,且目前在Debian Linux系统上仍可正常使用,已将geckodriver、Firefox、Selenium及相关库更新至最新版本,但问题未解决。

相关日志

[2024-01-02 17:03:40,768] [INFO] Using default request storage
[2024-01-02 17:03:40,783] [INFO] Created proxy listening on ::ffff:127.0.0.1:53812
[2024-01-02 17:03:40,795] [DEBUG] Started executable: `/Users/v/p/drivers/geckodriver_mac` in a child process with pid: 7630 using 0 to output -3
[2024-01-02 17:03:41,313] [DEBUG] POST http://localhost:53806/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts": true, "moz:debuggerAddress": true, "pageLoadStrategy": "normal", "proxy": {"proxyType": "manual", "httpProxy": "[::ffff:127.0.0.1]:53812", "sslProxy": "[::ffff:127.0.0.1]:53812"}, "moz:firefoxOptions": {"prefs": {"network.proxy.allow_hijacking_localhost": true}}}}}
[2024-01-02 17:03:41,442] [DEBUG] Remote response: status=500 | data={"value":{"error":"unknown error","message":"Process unexpectedly closed with status signal","stacktrace":""}} | headers=HTTPHeaderDict({'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-cache', 'content-length': '110', 'date': 'Tue, 02 Jan 2024 16:03:41 GMT'})
[2024-01-02 17:03:41,443] [DEBUG] Finished Request
[2024-01-02 17:03:41,444] [DEBUG] Cleaning up /var/folders/07/gxcrb9qd76lgrt90992jdn7c0000gn/T/.seleniumwire/storage-fac3f55b-22c1-4b2a-9bbb-03d61b5dbfbd
[2024-01-02 17:03:41,455] [ERROR] [Try 1/10] Message: Process unexpectedly closed with status signal

环境信息

  • MacOS Sonoma 14.2.1
  • Firefox 121.0
  • Geckodriver 0.33
  • Python 3.8.13

调试与修复思路

  • 检查geckodriver执行权限:MacOS下可能因权限不足导致无法运行,执行命令chmod +x /Users/v/p/drivers/geckodriver_mac赋予可执行权限。
  • 排查系统权限限制:
    • 检查系统隐私设置,确保Firefox和Python/geckodriver获得辅助功能权限(路径:系统设置 > 隐私与安全性 > 辅助功能)。
    • 若开启了系统完整性保护(SIP),可尝试临时关闭(重启Mac时按住Command+R进入恢复模式,执行csrutil disable后重启),测试是否解决问题(注意:关闭SIP有安全风险,测试后建议重新开启)。
  • 调整代理配置格式:日志中代理地址使用了IPv6格式[::ffff:127.0.0.1],可能在MacOS上存在兼容性问题,修改为纯IPv4地址127.0.0.1后重试。
  • 隔离测试组件:
    • 单独使用Selenium启动Firefox,排除SeleniumWire的影响,确认基础启动流程是否正常。
    • 直接运行geckodriver可执行文件,查看终端输出的详细日志,定位是否为geckodriver本身的问题。
  • 清理临时文件:手动删除SeleniumWire生成的临时存储目录(如日志中提到的/var/folders/07/gxcrb9qd76lgrt90992jdn7c0000gn/T/.seleniumwire/),或在代码中指定自定义的storage_path参数。
  • 尝试降级组件版本:新版本可能存在兼容性bug,尝试将geckodriver降级至0.32版本,或Firefox降级至120版本,验证问题是否消失。
  • 检查Firefox配置:
    • 为Selenium指定自定义Firefox配置文件,避免临时配置文件与系统默认配置冲突。
    • 在Firefox选项中禁用所有扩展和插件,排除第三方组件干扰。
  • 查看系统日志:执行命令log show --predicate 'process == "firefox" OR process == "geckodriver"' --info --debug,查看MacOS系统日志中进程终止的具体原因,获取更详细的错误线索。

内容的提问来源于stack exchange,提问作者Vitaly

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 20:02:26