简体   繁体   中英

“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). I'm using canopy (which is F# wrapper for Selenium). I put latest chromedriver in the same folder as my binary, version: 2.28.455506 (and I set the correct path to driver).

I'm starting chrome with --headless argument, like this:

  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 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

It's seems that it fails to set window size. Is it proper way to launch headless 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.

Also it's working fine on ma local Windows 10 machine with same version of chromedrive (just for 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

There's an open Chromium issue on this topic. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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