Merge "WebdriverIO should be able to run Chrome headlessly"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 10 Apr 2018 16:39:17 +0000 (16:39 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 10 Apr 2018 16:39:17 +0000 (16:39 +0000)
1  2 
tests/selenium/wdio.conf.js

@@@ -9,6 -9,10 +9,6 @@@ function relPath( foo ) 
  }
  
  exports.config = {
 -
 -      //
 -      // ======
 -      //
        // ======
        // Custom
        // ======
                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' ]
                }
        } ],
        //
        // Enables colors for log output.
        coloredLogs: true,
        //
 +      // Warns when a deprecated command is used
 +      deprecationWarnings: true,
 +      //
 +      // If you only want to run your tests until a specific amount of tests have failed use
 +      // bail (default is 0 - don't bail, run all tests).
 +      bail: 0,
 +      //
        // Saves a screenshot to a given path if a command fails.
        screenshotPath: './log/',
        //
 -      // Set a base URL in order to shorten url command calls. If your url parameter starts
 -      // with "/", then the base url gets prepended.
 +      // Set a base URL in order to shorten url command calls. If your `url` parameter starts
 +      // with `/`, the base url gets prepended, not including the path portion of your baseUrl.
 +      // If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
 +      // gets prepended directly.
        baseUrl: (
                process.env.MW_SERVER === undefined ?
                        'http://127.0.0.1:8080' :
        ),
        //
        // Default timeout for all waitFor* commands.
 -      waitforTimeout: 20000,
 +      waitforTimeout: 10000,
        //
        // Default timeout in milliseconds for request
        // if Selenium Grid doesn't send response
        // WebdriverRTC: https://github.com/webdriverio/webdriverrtc
        // Browserevent: https://github.com/webdriverio/browserevent
        // plugins: {
 -      //     webdrivercss: {
 -      //         screenshotRoot: 'my-shots',
 -      //         failedComparisonsRoot: 'diffs',
 -      //         misMatchTolerance: 0.05,
 -      //         screenWidth: [320,480,640,1024]
 -      //     },
 -      //     webdriverrtc: {},
 -      //     browserevent: {}
 +      //      webdrivercss: {
 +      //              screenshotRoot: 'my-shots',
 +      //              failedComparisonsRoot: 'diffs',
 +      //              misMatchTolerance: 0.05,
 +      //              screenWidth: [320,480,640,1024]
 +      //      },
 +      //      webdriverrtc: {},
 +      //      browserevent: {}
        // },
        //
        // Test runner services
        // Make sure you have the wdio adapter package for the specific framework installed
        // before running any tests.
        framework: 'mocha',
 -
 +      //
        // Test reporter for stdout.
        // The only one supported by default is 'dot'
        // see also: http://webdriver.io/guide/testrunner/reporters.html
        // it and to build services around it. You can either apply a single function or an array of
        // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
        // resolved to continue.
 -      //
 -      // Gets executed once before all workers get launched.
 -      // onPrepare: function ( config, capabilities ) {
 -      // }
 -      //
 -      // Gets executed before test execution begins. At this point you can access all global
 -      // variables, such as `browser`. It is the perfect place to define custom commands.
 +      /**
 +      * Gets executed once before all workers get launched.
 +      * @param {Object} config wdio configuration object
 +      * @param {Array.<Object>} capabilities list of capabilities details
 +      */
 +      // onPrepare: function (config, capabilities) {
 +      // },
 +      /**
 +      * Gets executed just before initialising the webdriver session and test framework. It allows you
 +      * to manipulate configurations depending on the capability or spec.
 +      * @param {Object} config wdio configuration object
 +      * @param {Array.<Object>} capabilities list of capabilities details
 +      * @param {Array.<String>} specs List of spec file paths that are to be run
 +      */
 +      // beforeSession: function (config, capabilities, specs) {
 +      // },
 +      /**
 +      * Gets executed before test execution begins. At this point you can access to all global
 +      * variables like `browser`. It is the perfect place to define custom commands.
 +      * @param {Array.<Object>} capabilities list of capabilities details
 +      * @param {Array.<String>} specs List of spec file paths that are to be run
 +      */
        // before: function (capabilities, specs) {
        // },
 -      //
 -      // Hook that gets executed before the suite starts
 -      // beforeSuite: function (suite) {
 +      /**
 +      * Runs before a WebdriverIO command gets executed.
 +      * @param {String} commandName hook command name
 +      * @param {Array} args arguments that command would receive
 +      */
 +      // beforeCommand: function (commandName, args) {
        // },
 -      //
 -      // Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
 -      // beforeEach in Mocha)
 -      // beforeHook: function () {
 +      /**
 +      * Hook that gets executed before the suite starts
 +      * @param {Object} suite suite details
 +      */
 +      // beforeSuite: function (suite) {
        // },
 -      //
 -      // Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
 -      // afterEach in Mocha)
 -      //
 -      // Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
 +      /**
 +      * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
 +      * @param {Object} test test details
 +      */
        // beforeTest: function (test) {
        // },
 -      //
 -      // Runs before a WebdriverIO command gets executed.
 -      // beforeCommand: function (commandName, args) {
 +      /**
 +      * Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
 +      * beforeEach in Mocha)
 +      */
 +      // beforeHook: function () {
        // },
 -      //
 -      // Runs after a WebdriverIO command gets executed
 -      // afterCommand: function (commandName, args, result, error) {
 +      /**
 +      * Hook that gets executed _after_ a hook within the suite ends (e.g. runs after calling
 +      * afterEach in Mocha)
 +      */
 +      // afterHook: function () {
        // },
 -      //
 -      // Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
 +      /**
 +      * Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) ends.
 +      * @param {Object} test test details
 +      */
        // from https://github.com/webdriverio/webdriverio/issues/269#issuecomment-306342170
        afterTest: function ( test ) {
                var filename, filePath;
                console.log( '\n\tScreenshot location:', filePath, '\n' );
        }
        //
 -      // Hook that gets executed after the suite has ended
 +      /**
 +      * Hook that gets executed after the suite has ended
 +      * @param {Object} suite suite details
 +      */
        // afterSuite: function (suite) {
        // },
 -      //
 -      // Gets executed after all tests are done. You still have access to all global variables from
 -      // the test.
 +      /**
 +      * Runs after a WebdriverIO command gets executed
 +      * @param {String} commandName hook command name
 +      * @param {Array} args arguments that command would receive
 +      * @param {Number} result 0 - command success, 1 - command error
 +      * @param {Object} error error object if any
 +      */
 +      // afterCommand: function (commandName, args, result, error) {
 +      // },
 +      /**
 +      * Gets executed after all tests are done. You still have access to all global variables from
 +      * the test.
 +      * @param {Number} result 0 - test pass, 1 - test fail
 +      * @param {Array.<Object>} capabilities list of capabilities details
 +      * @param {Array.<String>} specs List of spec file paths that ran
 +      */
        // after: function (result, capabilities, specs) {
        // },
 -      //
 -      // Gets executed after all workers got shut down and the process is about to exit. It is not
 -      // possible to defer the end of the process using a promise.
 -      // onComplete: function(exitCode) {
 +      /**
 +      * Gets executed right after terminating the webdriver session.
 +      * @param {Object} config wdio configuration object
 +      * @param {Array.<Object>} capabilities list of capabilities details
 +      * @param {Array.<String>} specs List of spec file paths that ran
 +      */
 +      // afterSession: function (config, capabilities, specs) {
 +      // },
 +      /**
 +      * Gets executed after all workers got shut down and the process is about to exit.
 +      * @param {Object} exitCode 0 - success, 1 - fail
 +      * @param {Object} config wdio configuration object
 +      * @param {Array.<Object>} capabilities list of capabilities details
 +      */
 +      // onComplete: function(exitCode, config, capabilities) {
        // }
  };