There are a few requirements that are needed to complete this tutorial.
ng new protractor-headless
So let’s try it out…
For this to work correctly we need to ensure firstly that both the application is being served at http://localhost:4200/, and we have a selenium web server is running. We already know our app is being served, so let's start a selenium server. Open up another terminal window and run:
In case you’re wondering where webdriver-manager came from, it’s installed as part of the Angular CLI. Here we’re simply updating the webdriver manager, and starting it.
Now that we know that the app is being served and a selenium server is running, we can start out test suite. Open up another terminal in the app root directory (protractor-headless), and run:
So we know our test passed. But we clearly aren’t using Headless Chrome, as we saw the Chrome GUI briefly. We need to make Protractor use Chrome with Headless Mode enabled.
Open up the protractor.conf.js, you’ll see:
We’re going to modify it to:
args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
And we’ll rerun the test suite:
It’s really that easy!