A Guide to Automated Testing with Drupal and Applitools

Automated Testing in Drupal

Behat, PHPUnit, Drupal Test Traits (DTT), and NightwatchJS are the most widely used tools for automating tests with Drupal. There are several reasons why these tools are popular within the Drupal community, such as all these tools are PHP-based frameworks (apart from NightwatchJS), offer ready to use Drupal extensions/plugins and have huge community support.

  1. One can quickly get started with writing actual tests with Cypress as compared to Selenium.
  2. Cypress enables fast-paced test execution.
  3. Our POC with Cypress + Drupal proved that testing the Drupal side of things can also be achieved with Cypress.
  4. Cypress offers harmonious integration with Applitools. Having said that, please note that Applitools does have SDKs for Selenium PHP and NightwatchJS and many more just in case you have your existing automation functional suites written using any of the other testing frameworks.
  5. Since Cypress is a JS-based framework, developers can also contribute to writing automated tests.

Applitools and Drupal

Applitools provides an SDK for Cypress which makes it very easy for us to integrate automated visual validation tests in the same functional test suite created using Cypress. The steps to configure Applitools with Cypress are straightforward and you can refer to their official documentation for more details. Let’s take a look at the test written for the Homepage. The gist as shown below:

  1. tag: The name of the test.
  2. target: Shall the window be targeted or a particular element?
  3. fully: Identify the scope, whether it is the current viewport or the entire window.

Interpreting the automated test execution results

Now that the tests have been executed, let’s look at the execution results, which brings us to the Applitools dashboard. Here’s the passed test result.

  1. “Search bar” in the header has shifted from its original position.
  2. The font-color for the “View recipe” button on the banner has changed.
  3. “Find out more” link in the footer.

Cross-browser/device/OS testing using the Ultrafast Test Cloud

Now that we have seen and understood how automated visual testing is done with one browser, let’s discuss some points that need to be accounted for to scale up your automated testing:

  1. Configure your suite to execute automated tests across several browsers and devices. However, not only the test authoring time increases but also creates a dependency on the technical staff as the logic for tests to run all tests across several browsers and devices need to be coded.
  2. Linear automated test execution increases execution time, thereby resulting in larger build times and delaying the feedback of the application to the entire team.
  3. Maintain an in-house grid for parallel execution or purchase additional subscriptions provided by Cloud-based solutions for parallel execution of automated tests.
  1. Number of browsers and devices = 7
  2. Total number of functional tests = 6
  3. Total number of visual tests = 7*6 = 42
  4. The time taken for complete execution on Ultrafast grid — 5 minutes 2 seconds

Other tools in the market

There are many other Open Source tools like BackstopJS, Shoov, Gemini, Visual regression service for WebdriverIO to name only a few, but none of the tools has the Applitools advantage and we will look at a few of many reasons in the coming section.

The Applitools Advantage

  1. The AI-driven image comparison algorithm is incredibly accurate and avoids false positives which otherwise occurs in a pixel-to-pixel based comparison. The amount of time it would take to troubleshoot false positives, especially on full-page screenshots would be time and cost-prohibitive. Pixel-based is ok for verifying small components across a short period of time, otherwise, it breaks down.
  2. Seamless integration with your existing functional automation suite through several Web, mobile, screenshot, desktop, and codeless SDKs available for testing and automation frameworks like Cypress, Selenium, WebdriverIO, Nightwatch, Appium, and also languages like PHP, Java, Javascript, C#, Python only to name a few.
  3. With the help of Ultrafast Test Cloud, your entire web application can be tested for visual accuracy at a fast speed (as the tests run only once whereas the visual rendering validations happen in parallel on several browsers and devices in the background) with guaranteed reliability and security.
  4. Applitools also provides out of the box integration with the Storybook component library for React, Vue and Angular.
  5. Learn more about the following Applitools Eyes integrations on their site:
  6. Integration with GitHub
  7. Integration with Microsoft Azure
  8. Integration with GitLab
  9. Integration with BitBucket
  10. Integration with Jira
  11. Integration with Email and Slack for notifications

What next?

Sign up for a free account with Applitools and feel free to clone this repository to try it out on your own. Integrate automated visual validation tests in your project that will help you build and release visually perfect web applications or websites confidently at a faster rate.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Applitools

Applitools

Deliver visually perfect web and mobile apps with AI-powered end-to-end visual testing & monitoring. Get started, free: http://bit.ly/ApplitoolsFree