Using Headless Chrome for your Selenium tests with WebdriverIO
Google announced in April that Headless Chrome was being shipped with Chrome 59 and Eric Bidelman provided the rundown on how to get started with using this new feature, give it a read if you have not.
The FAQ section of the post referred those who were interested in using Headless Chrome with Selenium tests to an article by intoli.com but unfortunately that article is from the perspective of Python.
I am going to show you how easy it is to wire Headless Chrome up with WebdriverIO and run your Selenium tests in with a Headless browser.
- Configure the capabilities property within the
args: ['--headless', '--disable-gpu', '--window-size=1280,800'],
binary: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
I’ve provided the above snippet to make it easy to copy and paste into your capabilities section of the
The flags being passed via
--headlessdenoting to run Headless mode
--disable-gpuis a temporary requirement to deal with known bugs
--window-sizesets the dimension of your Headless browser
binary points to the Chrome binary that supports Headless mode. If you did not update to Chrome 59, you will need to point to Chrome Canary.
The location of the binary differs from platform to platform, but here are common locations.
That’s all there is to it!
I hope this post gets people up and running with WebdriverIO and Headless Chrome!