Any way to start Google Chrome in headless mode?
TL;DR
google-chrome --headless --remote-debugging-port=9222 http://example.com
You'd also need --disable-gpu
temporarily.
Tutorial:
https://developers.google.com/web/updates/2017/04/headless-chrome
There's a work in progress: https://code.google.com/p/chromium/issues/detail?id=546953
The main deliverables are:
- A library which headless applications can link to to.
- A sample application which demonstrates the use of headless APIs.
So it would be possible to create a simple application that runs in console without connecting to display.
Update Apr 18 '16: The work is mainly done. There's a public forum now:
https://groups.google.com/a/chromium.org/forum/#!forum/headless-dev
Documentation is being in progress:
https://chromium.googlesource.com/chromium/src/+/master/headless/README.md
Update Sep 20 '16: It looks like chrome will eventually get the "--headless" parameter:
https://bugs.chromium.org/p/chromium/issues/detail?id=612904
There was a presentation on BlinkOn 6 (June 16/17, 2016)
Update Nov 29 '16: Design doc for --headless
flag: https://docs.google.com/document/d/1aIJUzQr3eougZQp90bp4mqGr5gY6hdUice8UPa-Ys90/edit#heading=h.qxqfzv2lj12s
Update Dec 13 '16: --headless
flag is expected to be available in Canary builds soon
Update Mar 12 '17: Chrome 57 has a --headless
flag working. Waiting for Selenium and other tools to catch up. User guide: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
How to start ChromeDriver in headless mode
UPDATE
Chrome version 60 is out so all you need to do is to download Chromdriver and Selenium via Nuget and use this simple code and everything works like a charm. Amazing.
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
...
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("headless");
using (var browser = new ChromeDriver(chromeOptions))
{
// add your code here
}
DATED
There is a solution until the official release of Chrome 60 will be released. You can download Chrome Canary and use headless with it. After installation set BinaryLocation to point to chrome canary also comment out the DebuggerAddress line(it forces chrome to timeout):
var chromeOptions = new ChromeOptions
{
BinaryLocation = @"C:\Users\2-as Aukstas\AppData\Local\Google\Chrome SxS\Application\chrome.exe",
//DebuggerAddress = "127.0.0.1:9222"
};
chromeOptions.AddArguments(new List<string>() { "no-sandbox", "headless", "disable-gpu" });
var _driver = new ChromeDriver(chromeOptions);
Using Watir WebDriver on headless Centos 6.4 (64 bit)
(I'm assuming from the error message that line 34 in code_lookup.rb
is the line browser = Watir::Browser.new :chrome
. If this is incorrect, this answer is probably as well.)
The reason your first script works is because the default browser in Watir-Webdriver is Firefox:
# From line 28 in https://github.com/watir/watir-webdriver/blob/master/lib/watir-webdriver/browser.rb
def start(url, browser = :firefox, *args)
In the second script, you specific :chrome
. Easy to solve if your goal is general purpose browsing: remove the :chrome
browser = Watir::Browser.new # <= same as :firefox
The hard part comes if you want to use Chrome specifically. It is not possible to 'correctly' install Chrome and the chromedriver on Centos 6.x, as it is not supported by Google (really). I've writen about this here, though I was on a 32-bit system, so hopefully you have more luck than I did.
The best answer I got on my StackOverflow question with the same content (no link -- it was down voted and subsequently auto-deleted) was to install something that has GLIBCXX_3.4.15 as a dependency. I was still unable to get chromedriver to recognize it was installed after doing so.
Related Topics
How to Change Port Number for Jenkins Installation in Ubuntu 12.04
Avrdude: Ser_Open(): Can't Open Device "/Dev/Ttyacm0": Device or Resource Busy
How to Remove Warning About Storing Unencrypted Password After Committing File in Svn
What's the Best Way to Find a String/Regex Match in Files Recursively? (Unix)
Why No Zero-Copy Networking in Linux Kernel
Start-Stop-Daemon Quoted Arguments Misinterpreted
Bumping Version Numbers for New Releases in Associated Files (Documentation)
Run Command After 1 Hour in Linux
What Makes the Gcc Std::List Sort Implementation So Fast
Must a Process Group Have a Running Leader Process
How to Read the Second-To-Last Line in a File Using Bash
What Is Kernel Section Mismatch
Linux Terminal: How to Capture or Watch Other Terminal Session
Critical Timing in an Arm Linux Kernel Driver
"Tput: No Value for $Term and No -T Specified " Error Logged by Cron Process