Screenshot Consistency

Some websites have moving or dynamic content. If your test script captures and compares screenshots from different points in the content's cycle, VisualTest may return diffs that are not visual bugs.

To address this, we recommend certain solutions depending on the content type:

Lazy-loaded content


With lazy-loaded content, the browser does not request images and other resources until the user takes some action, such as scrolling down the webpage. Test scripts not set up for lazy loading can produce patchy or blank captures.


The below solution will also handle content that is pre-loaded but animates or appears only when the user scrolls, such as CSS parallax (see example below).

Solution: Pre-load content

You can add code that scrolls the page from top to bottom, pre-loading and stabilizing all content before the screen is captured:

Dynamic content


Dynamic content updates frequently by design. The following are examples:

  • News sites - articles and images are rapidly replaced.

  • Weather sites - reports, graphics, and icons are updated regularly.

  • Counters - events such as page impressions are counted (see example below).

Solution 1: IgnoreElements

You can instruct VisualTest to leave specific elements out of the comparison. The process is as follows:


When using Element Type screenshots, note that Ignored Elements are not fully supported. This might result in inconsistencies in your results.

  1. Find the CSS selectors of the element(s) to ignore, as shown in the below image:

    • Right-click on the element and select Inspect.

    • Locate the element's div-class, div-ID, and so on in the HTML structure.

    • Right-click on the identified element.

    • From the context menu, select Copy > Copy Selector to copy it to the clipboard.

    How to find the CSS selector ID
  2. Paste this CSS selector into the script in place of the following examples:

Solution 2: Set comparison mode to Layout

When you set comparison mode to Layout, VisualTest searches for structural differences in layout rather than content or design changes. For examples and more information, see our Comparison mode section.

Animated content


Examples of animated content include the following:

  • Animated GIFs

  • CSS animations (see example below)

  • Videos

  • Custom JavaScript animations (including certain sliders and carousels - examples below)

VisualTest’s SDKs are designed to freeze animated content at the same point in its cycle from capture to capture. You can deal with elements that are not handled by this in one of two ways, expanded below in Solutions:

  1. Disable freezePage.

  2. For Custom JavaScript animations, write a script that pauses the animation.

Solution 1: Disable freezePage

To disable freezePage, add the below code to your script.

Solution 2: Pause Custom JavaScript Animation

Since there are many JavaScript plugins and custom implementations, you need to consider the following steps:

  1. Understand how your specific JavaScript implementation works on the site under test.

  2. Write the script accordingly, to pause the animation at the same point each time.

  3. Run the script in your Selenium test.

  4. Capture the screenshot with VisualTest.

In the following example, the carousel is implemented using a jQuery carousel plugin. Note how we set the carousel to pause consistently at the first slide before the capture: jQuery('.carousel').carousel(0)

Reference: moving content examples



CSS Parallax / Animations


See Also

Publication date: