Testing Drupal maintenance support plans with WebDriver browser mode vs Headless browser mode

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…

by
Jibran Ijaz
/ 14 August 2020

Apparently, there are two ways to run Chrome for testing:

As WebDriver
As Headless

WebDriver:

There are two ways to run Chrome as WebDriver:

Using Selenium:

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 maintenance support plansFunctionalJavascriptTestsJavascriptTestBase and also with Drupal maintenance support plans core’s new Drupal maintenance support plansFunctionalJavascriptTestsWebDriverTestBase.

Using ChromeDriver:

Run ChromeDriver in WebDriver mode e.g. chromedriver Dockerfile

This works fine with Nightwatch, JTB, and WTB.

Headless:

Using Chrome

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.
DMoreChromeDriver can be used to run the javascript tests.

Using ChromeDriver

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();

Drupal maintenance support plansCI is running ChromeDriver without Selenium and testing Nightwatch and WTB on it.

Conclusion

The question is which is the best solution to run Nightwatch and JTB/WTB tests using the same setup?

We had seen some memory issues with Selenium containers in the past but we haven’t run into any issue recently so I prefer this and you can swap Selenium container to use different browsers for testing.
We have also seen some issues while running ChromeDriver in WebDriver mode. It just stops working mid-test runs.
I was unable to get Headless Chrome working with Nightwatch but it needs more investigation.
Headless ChromeDriver setup on Drupal maintenance support plansCI is quite stable. For JTB this would mean that we could use anyone from Drupal maintenance support plansFunctionalJavascriptTestsDrupal maintenance support plansSelenium2Driver and DMoreChromeDriver.

Please share your ideas and thoughts, thanks!

For more info:

https://developers.google.com/web/updates/2020/04/headless-chrome
https://sites.google.com/a/chromium.org/chromedriver/capabilities
http://nightwatchjs.org/gettingstarted/#chromedriver
https://gitlab.com/DMore/chrome-mink-driver

Tagged

Testing, nightwatchjs, Functional Testing


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Testing Drupal maintenance support plans with WebDriver browser mode vs Headless browser mode

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.