繁体   English   中英

使用Selenium的无头铬(Ubuntu)出现“无法获得自动化扩展”错误

[英]“Cannot get automation extension” error on headless chrome with Selenium (Ubuntu)

我在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/_genic_background_page.html(会话信息:content shell =)(驱动程序信息:chromedriver = 2.28.455506(18f6627e265f442aeec9b6661a49fe819aeeea1f),在OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(OpenQA.Selenium.Remote.Response错误响应)[0x000d5]在平台= Linux的4.4.0-64泛型x86_64的)<2096f357ed27440a8e98c8a8dd645cdd>: OpenQA.Selenium.Remoter.Remote.Remote.Remote.0的<2096f357ed27440a8e98c8a8dd8cddd>:0中的OpenQA.Selenium.Remote.RemoteWebDriver.Execute为0(System.String driverCommandToExecute,System.Collections.Generic.Dictionary`2 [TKey,TValue]参数)[0x00046] .InternalExecute(System.String driverCommandToExecute,System.Collections.Generic.Dictionary 2 [TKey,TValue]参数)[0x00000]在OpenQA.Selenium.Remot中的<2096f357ed27440a8e98c8a8dd645cdd>:0中 e.RemoteWindow.set_Size(System.Drawing.Size值)[0x00067]在<2096f357ed27440a8e98c8a8dd645cdd>:0在canopy.core.pin(canopy.types +方向方向)[0x0002f]在<58c4b5b9d8107025a7450383core9b5c458> <58c4b5b9d8107025a7450383b9b5c458>:0中的开始(canopy.types + BrowserStartMode b)[0x0050c]

似乎无法设置窗口大小。 启动无头Chrome浏览器是否合适? 我在某处读到最新版本具有无头功能。 由于我使用的是Google Chrome和chromedriver的最新版本,因此我认为它不应该是版本不匹配的。

同样,它在具有相同版本chromedrive的本地Windows 10计算机上也可以正常工作(仅适用于Windows)。

使用命令运行(不带无头参数):

DISPLAY=:1 xvfb-run mono myapp.exe

似乎可以工作。 我认为这解决了我的问题。 我把它留给其他人寻找一种运行无头铬的方法,并且有同样的问题。

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

关于此主题,有一个公开的Chromium 问题 它指出:

无头模式目前不支持扩展,并且尚不清楚我们是否可以轻松地支持它们-尽管我们正在进行一些初步的可行性分析。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM