WebdriverIO should be able to run Chrome headlessly
authorŽeljko Filipin <zeljko.filipin@gmail.com>
Fri, 9 Jun 2017 13:40:31 +0000 (15:40 +0200)
committerZfilipin <zfilipin@wikimedia.org>
Thu, 29 Mar 2018 15:18:00 +0000 (15:18 +0000)
Chrome 59 introduced an headless mode, in this mode it does not need any
DISPLAY (Xorg, Xvfb...). That achieved by passing to chrome:

 --headless

Use headless when DISPLAY is not available. One can switch to headless
by simply unsetting the environment variable: unset(DISPLAY).

Bug: T167507
Signed-off-by: Antoine Musso <hashar@free.fr>
Change-Id: Id5424eafb20112fd74d472b8cef02cb15cafff89

tests/selenium/README.md
tests/selenium/wdio.conf.js

index 2dbf271..b15d407 100644 (file)
@@ -21,6 +21,11 @@ Set up MediaWiki-Vagrant:
 
     npm run selenium
 
+By default, Chrome will run in headless mode. If you want to see Chrome, set DISPLAY
+environment variable to any value:
+
+    DISPLAY=:1 npm run selenium
+
 To run only one file (for example page.js), you first need to spawn the chromedriver:
 
     chromedriver --url-base=wd/hub --port=4444
index 5eba0e0..f253d45 100644 (file)
@@ -84,9 +84,10 @@ exports.config = {
                maxInstances: 1,
                //
                browserName: 'chrome',
-               // Since Chrome v57 https://bugs.chromium.org/p/chromedriver/issues/detail?id=1625
                chromeOptions: {
-                       args: [ '--enable-automation' ]
+                       // Run headless when there is no DISPLAY
+                       // --headless: since Chrome 59 https://chromium.googlesource.com/chromium/src/+/59.0.3030.0/headless/README.md
+                       args: process.env.DISPLAY ? [] : [ '--headless' ]
                }
        } ],
        //