【问题标题】:Selenium::WebDriver::Error Chrome Crashed on M1 chipSelenium::WebDriver::Error Chrome 在 M1 芯片上崩溃
【发布时间】:2021-03-04 16:05:42
【问题描述】:

我花了几天时间尝试解决我遇到的以下代码:

caps = Selenium::WebDriver::Remote::Capabilities.chrome(
      "chromeOptions" => {
        :args => ['--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36 LegalMonsterNoBlock"']
      }
    )
    driver = Selenium::WebDriver.for :remote, url: selenium_host, :desired_capabilities => caps
    driver.get(url)

我正在尝试运行一个调用此方法的测试。测试运行良好。它打开 Chrome 运行测试,但每当我到达调用上述方法的应用程序部分时,测试就会失败并出现以下错误:

Minitest::UnexpectedError: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: crashed
          (chrome not reachable)
          (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
        Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
        System info: host: '7a6aaccda364', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.121-linuxkit', java.version: '1.8.0_232'
        Driver info: driver.version: unknown
        remote stacktrace: #0 0x0040004b6479 <unknown>

我的设置:

  • 配备 Apple M1 的 Macbook,运行 Big Sur 11.2.2
  • ruby 版本 2.7.2
  • ChromeDriver 89.0.4389.23(用于m1芯片)
  • Chrome 版本 89.0.4389.72(官方构建)(arm64)
  • gem selenium-webdriver 版本 3.142.3
  • 运行 docker selenium/standalone-chrome-debug:3.141.59-zinc

我已经尝试了几种方法:

  • --headless--no-sandbox 选项添加到argsargs =&gt; ['--headless', '--no-sandbox' ...
  • 通过 brew 安装 chromedriver 和 chrome 而不是下载二进制文件
  • 重新安装 chrome 和 chromedriver
  • 明确指定 chrome 和 chromedriver 的路径(Selenium::WebDriver::Chrome.path = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'Selenium::WebDriver::Chrome.driver_path="/path/to/chrome_driver_binary/chromedriver"

还有其他遇到此类问题的人吗?

【问题讨论】:

  • 我也有类似的问题。你找到解决方案了吗?
  • 我也面临这个问题

标签: selenium selenium-webdriver selenium-chromedriver apple-m1


【解决方案1】:

原来是我的docker镜像,不支持arm64架构,所以就是这一步: Running a docker selenium/standalone-chrome-debug:3.141.59-zinc.

如果我禁用了使用 docker 容器的部分测试,则没有问题。我想这对每个人来说都是不可能的,但我们希望很快会有一个支持 arm64 架构的 selenium 映像。

在此处查看Selenium issue

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 2022-12-25
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-11
    相关资源
    最近更新 更多