Senior Drupal Developer
There is not a lot of documentation available about what's the difference between running a browser in WebDriver mode vs Headless so I did some digging...
Apparently, there are two ways to run Chrome for testing:
There are two ways to run Chrome as WebDriver:
Run Selenium standalone server in WebDriver mode and pass the path of ChromeDriver bin along with the config e.g. Selenium Dockerfile
This works fine with Nightwatch standard setup, \Drupal\FunctionalJavascriptTests\JavascriptTestBase
and also with Drupal core's new \Drupal\FunctionalJavascriptTests\WebDriverTestBase
.
Run ChromeDriver in WebDriver mode e.g. chromedriver Dockerfile
This works fine with Nightwatch, JTB, and WTB.
Run Chrome browser binary in headless mode. e.g. Chrome headless Dockerfile
Nightwatch is not working with this set up, at least I was unable to configure it. See https://github.com/nightwatchjs/nightwatch/issues/1390 and https://github.com/nightwatchjs/nightwatch/issues/1439 for more info. \DMore\ChromeDriver
can be used to run the javascript tests.
Using Selenium ChromeDriver can be run in headless mode something like this:
const fs = require('fs');
const webdriver = require('selenium-webdriver');
const chromedriver = require('chromedriver');
const chromeCapabilities = webdriver.Capabilities.chrome();
chromeCapabilities.set('chromeOptions', {args: ['--headless']});
const driver = new webdriver.Builder()
.forBrowser('chrome')
.withCapabilities(chromeCapabilities)
.build();
DrupalCI is running ChromeDriver without Selenium and testing Nightwatch and WTB on it.
The question is which is the best solution to run Nightwatch and JTB/WTB tests using the same setup?
\Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver
and DMore\ChromeDriver
.Please share your ideas and thoughts, thanks!
For more info: