Best practices for optimal visual tests results

Eyes finds visual differences by comparing a checkpoint image to a baseline image and reporting differences that are significant, meaning differences that are noticeable to the human eye. In some applications, the nature of the content or the layout may lead to differences that are not significant from the application point of view. Eyes provides various tools that allow you to tweak the image capture and matching to deal with challenging page content or layout, or with special application requirements.

This article helps you optimize your test flow by describing scenarios in which Eyes reports mismatches when using the default configuration, and by describing how you can customize Eyes so that only relevant mismatches are reported.

Overview

Eyes provides various SDK configuration options and Test Manager tools that allow you to change how it captures images and compares checkpoint and baseline images. Customizing Eyes can save you time by allowing you to focus on differences that are significant for your application.

In order to decide what customization is required for a given situation, it is to useful to consider two questions:

  • Was the checkpoint image captured correctly?

  • Is the comparison of the checkpoint and baseline image appropriate?

This article is organized into two sections.

The first section describes situations where configuring the image capture can improve the results. The second section describes situations in which configuring the way matching is done can improve the results.

Customizing checkpoint capture

The list below describes some common scenarios related to checkpoint capture:

  • The checkpoint only includes what is visible in the browser viewport and does not include the content of the page that you can see by manually scrolling on the page.

  • The page is being scrolled and the entire page is captured, but some elements are missing, duplicated, or overlapping.

  • The page contains multiple scrolled regions, each of which needs to be scrolled to capture and validate all of the page content.

  • Small, random mismatches are reported, typically near input fields.

  • Mismatches are found on or near a scroll bar.

  • Elements are missing in the captured image. This may happen because the checkpoint is captured before the page is fully loaded, and is therefore not ready for validation, or if the page implements "lazy loading" and only updates the page when it is scrolled.

Customizing checkpoint/baseline matching

By default, the Eyes matching algorithms assume that the checkpoint and baseline images are, in principle, identical (i.e. they contain the same set of elements, the content of each element is the same, and the relative positions of the elements don't change). In some applications, the content may be dynamic, meaning that elements can have different text or graphics in different test runs, or that the size or position of elements can be different in different test runs. Eyes provides a variety of tools to enable visual validation of pages with dynamic content.

The list below describes some common scenarios in which you might need to change the way Eyes does matching in order to obtain relevant match results.

  • You are testing a page using A/B testing and getting mismatches every time the A/B test choice does not match the baseline.

  • The text or graphics are dynamic and can be different every test run. For example, a field that contains a date, or a targeted ad that is evaluated at run time, can create a mismatch with the value in that field in the baseline image. You want to validate the layout of the fields but not the dynamic content that changes.

  • The position of an element is dynamic and can change in different test runs, but the move is reported as a mismatch. The maximum the element can move in any direction is known.

  • A change in size of an element causes many other elements to move, and these moves are reported as differences. You are only interested in getting reports of elements that have appeared, disappeared, or changed but do not want to get mismatch reports regarding elements that have only moved.

  • The page contains text or graphics that you don't want to validate, for example, because they are dynamic, or because they contain animated content such as video.