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

Electron.js应用在Mac M1上使用Selenium WebDriver运行缓慢问题求助

Electron + Selenium 在Mac M1上运行缓慢的问题

我用Electron.js开发了一款基于Selenium WebDriver实现Chrome自动化操作的应用,在Windows和Mac Intel平台运行稳定流畅,但在Mac M1设备上速度极慢。

使用的依赖项

"dependencies": {
    "axios": "^1.4.0",
    "chromedriver": "^113.0.0",
    "date-fns": "^2.30.0",
    "dotenv": "^16.1.4",
    "electron": "^24.3.0",
    "electron-chromedriver": "^24.0.0",
    "electron-squirrel-startup": "^1.0.0",
    "selenium-webdriver": "^4.9.2"
}

解决方法

  • 适配ARM架构的驱动版本:当前依赖的chromedriver是x86版本,在M1设备上会通过Rosetta转译运行,直接拖慢速度。换成ARM原生版本的ChromeDriver,同时确保electron-chromedriver版本和Electron版本严格匹配(比如都用24.3.x)。
  • 关闭Rosetta转译:找到你的Electron应用,右键选择「显示简介」,取消勾选「使用Rosetta打开」,强制应用以原生ARM模式运行。
  • 更新依赖版本:把selenium-webdriver升级到最新稳定版,新版本通常会优化ARM平台的兼容性;同步升级electron和electron-chromedriver到同版本,避免版本不匹配引发的性能问题。
  • 优化自动化操作逻辑:减少不必要的DOM重复查询,用WebDriverWait替代固定时间的sleep等待,避免频繁页面刷新——这类操作在转译环境下的性能损耗会被放大。
  • 检查Chrome版本:确保M1设备上安装的是ARM原生版本的Chrome浏览器,而非x86版本,Selenium连接原生浏览器能大幅提升运行速度。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 22:14:56