Skip to content

Instantly share code, notes, and snippets.

@TuHuynhVan
Forked from christian-bromann/Readme.md
Created May 18, 2017 17:20
Show Gist options
  • Save TuHuynhVan/4f211255f25ccf62e0f1c1cd6d7fc0a0 to your computer and use it in GitHub Desktop.
Save TuHuynhVan/4f211255f25ccf62e0f1c1cd6d7fc0a0 to your computer and use it in GitHub Desktop.
Run Chrome headless

Run Chrome headless

The good old PhantomJS times are over. The project is not maintained anymore and it is recommended to switch over to Chrome headless. Just run a local Selenium standalone server:

$ java -jar Sites/selenium-server-standalone-3.4.0.jar

and run a test with the config below. This is tested with Mac OS X and Windows 10. If you have more questions, join our Gitter for support.

describe('runs in headless Chrome', () => {
it('opens website without browser window', () => {
browser.url("http://webdriver.io")
console.log(browser.getTitle())
})
});
var readline = require('readline')
var hasTriggered = false
exports.config = {
specs: ['./test.spec.js'],
capabilities: [{
browserName: 'chrome',
chromeOptions: {
// run in headless mode
args: ['--headless'],
// point to your Canary version as it is only supported there
binary: '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
}
}],
framework: 'mocha',
mochaOpts: {
timeout: 10000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment