简体   繁体   English

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

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

I've installed latest Google Chrome 57.0.2987.110, on my Ubuntu server (16.04). 我在Ubuntu服务器(16.04)上安装了最新的Google Chrome 57.0.2987.110。 I'm using canopy (which is F# wrapper for Selenium). 我正在使用冠层(Selenium的F#包装器)。 I put latest chromedriver in the same folder as my binary, version: 2.28.455506 (and I set the correct path to driver). 我将最新的chromedriver和我的二进制文件放在同一文件夹中:2.28.455506(并设置了正确的驱动程序路径)。

I'm starting chrome with --headless argument, like this: 我正在使用--headless参数启动chrome,如下所示:

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

  start <| ChromeWithOptions chromeOpts

As soon as it's starts I get this error: 一旦启动,我会收到此错误:

[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html (Session info: content shell=) (Driver info: chromedriver=2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f),platform=Linux 4.4.0-64-generic x86_64) at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError (OpenQA.Selenium.Remote.Response errorResponse) [0x000d5] in <2096f357ed27440a8e98c8a8dd645cdd>:0 at OpenQA.Selenium.Remote.RemoteWebDriver.Execute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary`2[TKey,TValue] parameters) [0x00046] in <2096f357ed27440a8e98c8a8dd645cdd>:0 at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary 2[TKey,TValue] parameters) [0x00000] in <2096f357ed27440a8e98c8a8dd645cdd>:0 at OpenQA.Selenium.Remot [错误]致命异常: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 value) [0x00067] in <2096f357ed27440a8e98c8a8dd645cdd>:0 at canopy.core.pin (canopy.types+direction direction) [0x0002f] in <58c4b5b9d8107025a7450383b9b5c458>:0 at canopy.core.start (canopy.types+BrowserStartMode b) [0x0050c] in <58c4b5b9d8107025a7450383b9b5c458>: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]

It's seems that it fails to set window size. 似乎无法设置窗口大小。 Is it proper way to launch headless Chrome? 启动无头Chrome浏览器是否合适? I read somewhere that newest version has headless feature. 我在某处读到最新版本具有无头功能。 As I'm using newest version of both Google Chrome and chromedriver I think it shouldn't be a version mismatch. 由于我使用的是Google Chrome和chromedriver的最新版本,因此我认为它不应该是版本不匹配的。

Also it's working fine on ma local Windows 10 machine with same version of chromedrive (just for windows). 同样,它在具有相同版本chromedrive的本地Windows 10计算机上也可以正常工作(仅适用于Windows)。

Running with command (and without headless argument): 使用命令运行(不带无头参数):

DISPLAY=:1 xvfb-run mono myapp.exe

Seems to work. 似乎可以工作。 I think this resolves my issue. 我认为这解决了我的问题。 I leave it here for others looking for a way tu run headless chrome and having same problem. 我把它留给其他人寻找一种运行无头铬的方法,并且有同样的问题。

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

There's an open Chromium issue on this topic. 关于此主题,有一个公开的Chromium 问题 It states: 它指出:

Headless mode doesn't currently support extensions, and it's not clear whether we can support them easily -- although we are doing some initial feasibility analysis. 无头模式目前不支持扩展,并且尚不清楚我们是否可以轻松地支持它们-尽管我们正在进行一些初步的可行性分析。

As suggested by @mateuszlewko, the X Virtual Framebuffer (XVFB) can be used as a Linux workaround. 如@mateuszlewko所建议,X虚拟帧缓冲区(XVFB)可用作Linux解决方法。

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

相关问题 错误:无法获取含硒铬的自动化扩展 - Error:cannot get automation extension for chrome with selenium 使用chrome 54.0.2840.71“无法获得自动化扩展”错误 - “cannot get automation extension” error with chrome 54.0.2840.71 在 Chrome 上截屏时,Selenium Webdriver 错误(无法获得自动化扩展) - Selenium Webdriver Error (Cannot get automation extension) while taking screenshot on Chrome chrome版本出现“无法获得自动化扩展”错误:57.0.2987.98 - “cannot get automation extension” error with chrome version: 57.0.2987.98 Chrome - org.openqa.selenium.WebDriverException:未知错误:无法在driver.manage()获取自动化扩展.window()。maximize(); - Chrome - org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension at driver.manage().window().maximize(); 未知错误:无法获得自动化扩展 - unknown error: cannot get automation extension 水豚,硒,无头Chrome,Ubuntu Net :: ReadTimeout - Capybara, Selenium, headless Chrome, Ubuntu Net::ReadTimeout Selenium 崩溃:Chrome 自动化扩展程序崩溃 - Selenium Crashing: Chrome automation extension has crashed 无头铬无法检测元素(硒) - Headless chrome cannot detect elements(selenium) .NET 使用 Selenium 进行测试,无头 Chrome 错误 - .NET Tests with Selenium, headless Chrome error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM