Project: chromium Issues People Development process History Sign in
New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Issue 604324 Selenium support for headless
Starred by 86 users Project Member Reported by skyos...@chromium.org, Apr 18 2016 Back to list
Status: Assigned
Owner:
Cc:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug


Sign in to add a comment
This bug tracks the work needed to make it possible to use Headless Chrome as a back-end in Selenium
 
Labels: Proj-Headless
Labels: OS-Windows
Hi, is there any timeline for selenium support for headless chrome?
Blockedon: 612904
I think we can look at this after bug 612904 is done.
I already use selenium with the headless_shell like this (in Java):


HashMap<String,String> env = new HashMap<>();
env.put("CHROME_DEVEL_SANDBOX", "/home/paulo/headless_chrome/chrome-devel-sandbox");
ChromeDriverService cs = new ChromeDriverService.Builder()
        .withEnvironment(env)
        .usingDriverExecutable(new File(......))
        .build();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.setBinary("/home/paulo/headless_chrome/headless_shell");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(cs,capabilities);


Does bug 612904 imply that headless_shell is going to disappear and be replaced by chrome called with a headless parameter?
No both headless_shell and a --headless for chrome will coexist.
I think headless shell will be around for a while longer, but longer term I think we should kill it in favor of everyone using Chrome proper with a --headless flag. The reason is that Chrome 1) auto-updates and 2) runs on more than just Linux.
Comment 8 by amo...@gmail.com, Sep 27 2016
Part of the appeal of using headless_shell is that it's lightweight and has a lot less lib dependencies than Chrome. Using the headless flag with Chrome and killing headless_shell would also kill that advantage if I read this correctly.
True, we'll still need 90% of the code in headless shell, so keeping the binary around too is not a huge burden. We'll keep your comments in mind.
Labels: HeadlessUpForGrabs
Cc: eseckler@chromium.org
Any progress? I run it with
            options.addArguments("headless");
            options.addArguments("start-maximized");
            options.addArguments("disable-gpu");
            options.addArguments("no-sandbox");
            options.addArguments("disable-popup-blocking");
            options.addArguments("v9");
            options.addArguments("screenshot");
            options.addArguments("always-authorize-plugins");
and got the following errors (hope it will help any others to find this issue) :

There were 2 errors:
  org.openqa.selenium.WebDriverException(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.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 2.6.32-44-pve x86_64) (WARNING: The server did not provide any stacktrace information)
Cc: samu...@chromium.org
There are a few features of webdriver / chromedriver that aren't supported by headless at the moment. Extensions are one of them, and chromedriver uses an extension for some operations, e.g. to set the window size. Until we modify chromedriver/headless to support these operations, you can try to work around the restriction by avoiding these operations. (For window size, there's also a command line flag, e.g. --window-size=800x600, that might work for you instead.)
Thanks, it started to work with
            capabilities.setCapability("nativeEvents", false);
            capabilities.setCapability("takesScreenshot", false);
and removed browser.manage().window().maximize();
, but then failed on sendKeys call. Seems like keys and mouse events is also unsupported. Ok, I agree to wait.
To add to #c13, some things will work, some things won't. I've put together a doc listing some of the obvious things that are missing: https://docs.google.com/document/d/17VbJpJ9THEEsmy78Io3hbjHJs5dVy8eQ1kx9BNL6Ydo/edit?usp=sharing
Hey #c15 (samu...)

Could we add that window popups are not working with the headless_shell as well please? I didn't see that in the document. Not sure if its anything the team plan on addressing soon ?

You can verify with the following command;

headless_shell --remote-debugging-port=9222 --window-size=1280,1024 http://html.com/javascript/popup-windows/

Open the devtools on in a browser click on the link my popup under the section 'The Basics' - observe no errors/logs from either headless_shell or the devtools console

It isn't specific to that web page - but also on our internal app ran by the test suite which uses the pop windows for oauth(2) authorization flow. Driven by selenium webdriver chromedriver. It appears is it able to see the page content - but is unable to interact with the popup window.

I can create a bug but felt as you had a document with the things that won't work - that probably would be the place for now ? If not let me know.

Also thanks for your work on the headless_shell/chromium
Blockedon: 696439
#16: Sounds like something we should investigate. Filed https://crbug.com/696439.
Owner: jzfeng@chromium.org
Status: Assigned
Handed off to jzfeng@ who's going to start porting some of the features currently implemented by the ChromeDriver extension to DevTools.
Project Member Comment 20 by bugdroid1@chromium.org, Mar 14
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c75dbfd25cc376b92a494d340259056a01e1432e

commit c75dbfd25cc376b92a494d340259056a01e1432e
Author: irisu <irisu@chromium.org>
Date: Tue Mar 14 09:34:34 2017

Add headless chrome as an accepted browser string in chromedriver.

This is working towards selenium support for headless see https://bugs.chromium.org/p/chromium/issues/detail?id=604324

BUG= 699382 ,604324

Review-Url: https://codereview.chromium.org/2731403008
Cr-Commit-Position: refs/heads/master@{#456660}

[modify] https://crrev.com/c75dbfd25cc376b92a494d340259056a01e1432e/chrome/test/chromedriver/chrome/browser_info.cc
[modify] https://crrev.com/c75dbfd25cc376b92a494d340259056a01e1432e/chrome/test/chromedriver/chrome/browser_info_unittest.cc

Blocking: chromedriver:639
Project Member Comment 22 by bugdroid1@chromium.org, Mar 31
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d6cc35e9043b01bfffaf3164bee1c5310cdedcf7

commit d6cc35e9043b01bfffaf3164bee1c5310cdedcf7
Author: samuong <samuong@chromium.org>
Date: Fri Mar 31 04:37:36 2017

[chromedriver] Introduce chromeOptions.useAutomationExtension.

This allows clients to enable or disable the ChromeDriver automation extension.
It is currently true by default, but once we introduce DevTools commands to
replace the extension, we'll set this to false by default, and later remove it.

BUG=604324
TBR=stgao@chromium.org

Review-Url: https://codereview.chromium.org/2785413002
Cr-Commit-Position: refs/heads/master@{#461032}

[modify] https://crrev.com/d6cc35e9043b01bfffaf3164bee1c5310cdedcf7/chrome/test/chromedriver/capabilities.cc
[modify] https://crrev.com/d6cc35e9043b01bfffaf3164bee1c5310cdedcf7/chrome/test/chromedriver/capabilities.h
[modify] https://crrev.com/d6cc35e9043b01bfffaf3164bee1c5310cdedcf7/chrome/test/chromedriver/chrome_launcher.cc
[modify] https://crrev.com/d6cc35e9043b01bfffaf3164bee1c5310cdedcf7/chrome/test/chromedriver/test/run_py_tests.py

Project Member Comment 23 by bugdroid1@chromium.org, Apr 8
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd

commit 24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd
Author: jzfeng <jzfeng@chromium.org>
Date: Sat Apr 08 02:30:10 2017

add a new set of commands to resize and position windows

https://docs.google.com/a/google.com/document/d/1iDSRQzYiF6xYKp2PuA8kBmghK7Ar0OZXQZFsaUBNgKw/edit?usp=sharing

Devtools side, add a new UI domain and methods:
method: getWindowForTarget, param: targetID, return: windowID, bounds.
method: setWindowBounds, param: windowID, bounds
method: getWindowBounds, param: windowID, return: bounds

bounds object: left, top, width, height, window_state (minimized, maximized, fullscreen, normal)

BUG=604324

Review-Url: https://codereview.chromium.org/2734123004
Cr-Commit-Position: refs/heads/master@{#463110}

[modify] https://crrev.com/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
[modify] https://crrev.com/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd/chrome/browser/devtools/chrome_devtools_manager_delegate.h
[modify] https://crrev.com/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd/chrome/browser/devtools/devtools_protocol.cc
[modify] https://crrev.com/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd/chrome/browser/devtools/devtools_protocol.h
[modify] https://crrev.com/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd/chrome/browser/devtools/devtools_sanity_browsertest.cc
[modify] https://crrev.com/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd/third_party/WebKit/LayoutTests/inspector/schema-get-domains-matches-agents-expected.txt
[modify] https://crrev.com/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd/third_party/WebKit/Source/core/inspector/browser_protocol.json

Make a copy of the doc: Migrate chromedriver extension to devtool commands
https://docs.google.com/document/d/1Q0kuHgU1d-sj8gePjEU9nHtlQzz5rNvvGH8fCJ3iBq4/edit?usp=sharing.

This version is shared to public.
Project Member Comment 26 by bugdroid1@chromium.org, Apr 10
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20

commit da1d85c561f4c7b666dfc1ae5acb3310d9b78a20
Author: jzfeng <jzfeng@chromium.org>
Date: Mon Apr 10 20:54:36 2017

Revert of add a new set of commands to resize and position windows (patchset #35 id:680001 of https://codereview.chromium.org/2734123004/ )

Reason for revert:
It cause flaky browser tests on mac10.10

https://uberchromegw.corp.google.com/i/chromium.mac/builders/Mac10.10%20Tests?numbuilds=100

Original issue's description:
> add a new set of commands to resize and position windows
>
> https://docs.google.com/document/d/1Q0kuHgU1d-sj8gePjEU9nHtlQzz5rNvvGH8fCJ3iBq4/edit?usp=sharing
>
> Devtools side, add a new UI domain and methods:
> method: getWindowForTarget, param: targetID, return: windowID, bounds.
> method: setWindowBounds, param: windowID, bounds
> method: getWindowBounds, param: windowID, return: bounds
>
> bounds object: left, top, width, height, window_state (minimized, maximized, fullscreen, normal)
>
> BUG=604324
>
> Review-Url: https://codereview.chromium.org/2734123004
> Cr-Commit-Position: refs/heads/master@{#463110}
> Committed: https://chromium.googlesource.com/chromium/src/+/24a8ad434aab59c8c8a08ba02d934ca5fdfdc7dd

TBR=dgozman@chromium.org,pfeldman@chromium.org,samuong@chromium.org

Review-Url: https://codereview.chromium.org/2808923002
Cr-Commit-Position: refs/heads/master@{#463388}

[modify] https://crrev.com/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
[modify] https://crrev.com/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20/chrome/browser/devtools/chrome_devtools_manager_delegate.h
[modify] https://crrev.com/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20/chrome/browser/devtools/devtools_protocol.cc
[modify] https://crrev.com/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20/chrome/browser/devtools/devtools_protocol.h
[modify] https://crrev.com/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20/chrome/browser/devtools/devtools_sanity_browsertest.cc
[modify] https://crrev.com/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20/third_party/WebKit/LayoutTests/inspector/schema-get-domains-matches-agents-expected.txt
[modify] https://crrev.com/da1d85c561f4c7b666dfc1ae5acb3310d9b78a20/third_party/WebKit/Source/core/inspector/browser_protocol.json

Project Member Comment 27 by bugdroid1@chromium.org, Apr 13
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f

commit dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f
Author: jzfeng <jzfeng@chromium.org>
Date: Thu Apr 13 02:59:17 2017

Add a new set of commands to resize and position windows

https://docs.google.com/document/d/1Q0kuHgU1d-sj8gePjEU9nHtlQzz5rNvvGH8fCJ3iBq4/edit?usp=sharing

Devtools side, add a new UI domain and methods:
method: getWindowForTarget, param: targetID, return: windowID, bounds.
method: setWindowBounds, param: windowID, bounds
method: getWindowBounds, param: windowID, return: bounds

bounds object: left, top, width, height, window_state (minimized, maximized, fullscreen, normal)

BUG=604324

Review-Url: https://codereview.chromium.org/2813553005
Cr-Commit-Position: refs/heads/master@{#464265}

[modify] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/chrome/browser/devtools/chrome_devtools_manager_delegate.cc
[modify] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/chrome/browser/devtools/chrome_devtools_manager_delegate.h
[modify] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/chrome/browser/devtools/devtools_protocol.cc
[modify] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/chrome/browser/devtools/devtools_protocol.h
[add] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/chrome/browser/devtools/devtools_sanity_interactive_browsertest.cc
[modify] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/chrome/test/BUILD.gn
[modify] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/third_party/WebKit/LayoutTests/inspector/schema-get-domains-matches-agents-expected.txt
[modify] https://crrev.com/dd0fef609820bee5b4e9b6aa46dd4ee3dd53f81f/third_party/WebKit/Source/core/inspector/browser_protocol.json

Blockedon: chromedriver:1772
Sign in to add a comment