【问题标题】:"Cannot get automation extension" error on headless chrome with Selenium (Ubuntu)使用 Selenium(Ubuntu)的无头 chrome 上的“无法获得自动化扩展”错误
【发布时间】:2017-03-24 14:21:42
【问题描述】:

我在我的 Ubuntu 服务器 (16.04) 上安装了最新的 Google Chrome 57.0.2987.110。 我正在使用树冠(这是 Selenium 的 F# 包装器)。 我将最新的 chromedriver 放在与我的二进制文件相同的文件夹中,版本:2.28.455506(并且我设置了正确的驱动程序路径)。

我正在使用--headless 参数启动chrome,如下所示:

  let chromeOpts = ChromeOptions ()
  chromeOpts.AddArgument "--headless"
  chromeOpts.AddArgument "--disable-gpu"
  chromeOpts.AddArgument "start-maximized"

  start <| ChromeWithOptions chromeOpts

一开始我就收到这个错误:

[错误] 致命的未处理异常:System.InvalidOperationException:未知错误:无法获得自动化扩展 来自未知错误:找不到页面:chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html (会话信息:内容外壳=) (驱动程序信息:chromedriver=2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f),平台=Linux 4.4.0-64-generic x86_64) 在 OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError (OpenQA.Selenium.Remote.Response errorResponse) [0x000d5] 在 :0 在 OpenQA.Selenium.Remote.RemoteWebDriver.Execute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary`2[TKey,TValue] 参数) [0x00046] in :0 在 OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary 2[TKey,TValue] 参数) [0x00000] in :0 在 OpenQA.Selenium.Remote.RemoteWindow.set_Size (System.Drawing.Size 值) [0x00067] 在 :0 在 canopy.core.pin (canopy.types+direction 方向) [0x0002f] in :0 在 canopy.core.start (canopy.types+BrowserStartMode b) [0x0050c] in :0

似乎无法设置窗口大小。 启动无头 Chrome 的正确方法是什么?我在某处读到最新版本具有无头功能。 由于我使用的是最新版本的 Google Chrome 和 chromedriver,我认为这不应该是版本不匹配。

此外,它在具有相同版本 chromedrive 的本地 Windows 10 机器上运行良好(仅适用于 Windows)。

【问题讨论】:

    标签: google-chrome selenium selenium-webdriver selenium-chromedriver canopy-web-testing


    【解决方案1】:

    使用命令运行(并且没有无头参数):

    DISPLAY=:1 xvfb-run mono myapp.exe

    似乎有效。我认为这解决了我的问题。 我把它留在这里,让其他正在寻找一种方式运行无头 chrome 并遇到同样问题的人。

    本解决方案来自:http://coderscoffeehouse.com/tech/2017/01/17/headless-front-end-testing-on-linux-using-fsharp.html

    【讨论】:

    • 请不要忘记回来并将其标记为答案。谢谢!
    【解决方案2】:

    关于这个主题有一个开放的 Chromium issue。它指出:

    无头模式目前不支持扩展,不清楚 我们是否可以轻松地支持他们——尽管我们正在做一些 初步可行性分析。

    正如@mateuszlewko 所建议的,X ​​虚拟帧缓冲区 (XVFB) 可用作 Linux 解决方法。

    【讨论】:

      猜你喜欢
      • 2018-04-29
      • 2017-08-05
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      • 2019-10-22
      相关资源
      最近更新 更多