Skip to content
Tutorials Center
My learning

Topics

Lesson 41 of 60 ยท Manual Testing in Practice

Visual and GUI Testing

Learn GUI testing and visual regression testing: what to check on screens, baseline images, diffs and thresholds, approaches, tools, and ways to reduce flakiness.

Users do not see your code. They see a screen. A page can pass every functional check and still be broken for people: a button hidden behind a banner, text overflowing its box, a logo that suddenly turns huge, a dark-mode color that makes labels unreadable. GUI testing checks the graphical user interface for correct behavior and appearance, and visual testing (visual regression testing) specifically compares how the screen looks with how it looked before.

This lesson covers what to check, how screenshot comparison works, where it goes wrong, and the tool families. It continues from Web UI and Usability Testing.

What GUI testing covers

  • Layout and alignment: elements in the right place, no overlap, consistent spacing.
  • Content: correct text, labels, images, icons, no truncation or overflow, correct translations (see Compatibility and Localization Testing).
  • Controls: buttons, links, menus, forms, dropdowns and dialogs respond properly and show correct states (hover, focus, disabled, error, loading).
  • Navigation: the user can move between screens and return.
  • Responsiveness: the layout adapts to screen sizes and orientation.
  • Style: fonts, colors and branding match the design system, in light and dark themes.
  • Accessibility basics: focus order, contrast and labels (see the accessibility section in Web UI and Usability Testing).
  • Error and empty states: what the screen shows with no data, too much data, or a failed request.

GUI testing can be manual (exploring with a checklist), scripted (automated clicks and assertions), or visual (image comparison).

The problem with functional automation

An automated test that clicks "Add to cart" and checks the cart count can pass while the button is invisible or the cart icon is cut off. Assertions look at the DOM or the data, not at pixels. A human notices layout problems instantly; a script does not. Visual testing fills that gap by comparing images.

How visual regression testing works

  1. Capture a baseline. Take screenshots of pages or components in a known-good state, at fixed browser, viewport and theme.
  2. Run again after a change. Capture the same screens with the new code.
  3. Compare each new image with its baseline, pixel by pixel or with a smarter algorithm.
  4. Report differences. The tool highlights changed areas in a diff image.
  5. A human reviews. If the change is intended (a redesign), approve it and the new image becomes the baseline. If it is a bug, fix the code.
flowchart LR
  B["Baseline<br/>approved screenshot"] --> C["Compare"]
  N["New screenshot<br/>after the change"] --> C
  C --> D{"Difference above<br/>threshold?"}
  D -- no --> P["Pass"]
  D -- yes --> R["Diff image for human review"]
  R --> A["Approve: update baseline"]
  R --> F["Reject: fix the bug"]

Baselines are the contract. Approving a diff is a deliberate decision.

Comparison approaches

  • Pixel-to-pixel: any pixel difference counts. Precise, but noisy: a one-pixel shift from font anti-aliasing can fail a test.
  • Threshold: pass if fewer than a small percentage of pixels differ, or each pixel's color difference is below a tolerance.
  • Structural or perceptual algorithms: compare shapes and regions the way a person would, ignoring invisible noise.
  • AI-assisted: some commercial tools use machine learning to decide whether a change is meaningful.
  • DOM or layout snapshot: compare element positions and styles instead of images, which is faster and more stable but misses rendering issues.

Making visual tests stable

Visual tests have a reputation for flakiness. Most failures come from environmental noise, and you can prevent them:

  • Same browser, version, OS and fonts for baseline and comparison; run in a container to guarantee it.
  • Fixed viewport size and device pixel ratio.
  • Wait for the page to settle: web fonts loaded, images loaded, animations finished (disable animations in test mode).
  • Freeze dynamic content: mock the clock, random data, ads and carousels; hide or mask areas that always change, such as timestamps.
  • Use test data that never changes.
  • Test components in isolation (a style guide page or Storybook-like stories) for small, stable images, plus a few full pages.
  • Keep the set small and meaningful. Dozens of well-chosen screens beat thousands of noisy ones.

Tools

You do not need to compare images yourself. Typical tools:

  • Built-in screenshot assertions in browser test frameworks, such as Playwright's toHaveScreenshot and Cypress image-snapshot plugins.
  • Open-source libraries: BackstopJS, Loki, Reg-suit, pixelmatch (a comparison library).
  • Cloud services: Percy, Chromatic, Applitools and others, which add cross-browser rendering, review workflows and smarter comparison.
  • For desktop and mobile apps: screenshot testing libraries of each platform, such as Paparazzi or Shot on Android and snapshot testing on iOS.

Tool names and prices change; evaluate them with a small pilot on your own screens.

Try it: a pixel comparison with a threshold

A screenshot is just a grid of colors. This stand-in compares two tiny "images" (a grid of brightness numbers) to show how a pixel diff, a tolerance and a changed-area percentage behave.

JS Compare two tiny screenshots

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The tolerance removes the one-pixel noise while the shifted block, the real change, stays visible. Choosing the tolerance is a trade-off: too tight and you drown in false alarms, too loose and you miss real defects.

Try it: a baseline approval workflow

This stand-in models the review step: a store of baselines, a run that classifies each screen as unchanged, changed or new, and an approval that updates a baseline.

JS Baselines, diffs and approval

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The social part matters as much as the technology: someone must own baseline review, or diffs get approved without being looked at.

Manual GUI testing checklist

Even with automation, run a human pass for each release:

  • Resize the window from phone width to wide desktop.
  • Check every state: loading, empty, error, success, long text, very long names.
  • Zoom to 200 percent and increase the browser's default font size.
  • Switch themes (light, dark, high contrast) and languages.
  • Tab through the page with the keyboard and look at focus indicators.
  • Compare against the design file, especially spacing and fonts.
  • Try at least two different browsers and one real phone.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why can a functional UI test pass even though a button is invisible?

    Functional assertions usually check elements and values, not whether a human can see them, which is the gap visual testing fills.
  2. 2. What is a baseline in visual regression testing?

    New screenshots are compared with the approved baseline images.
  3. 3. A visual test fails on every run because a clock widget shows the time. What is the best fix?

    Make the screen deterministic by mocking or masking content that always changes, so real differences stand out.
  4. 4. A visual diff shows an intended redesign. What should the reviewer do?

    Intentional changes are approved and replace the baseline; unintended ones are fixed.

Summary

  • GUI testing checks layout, content, controls, responsiveness and states; visual testing compares screenshots with approved baselines.
  • Pixel diffs need tolerances; stability comes from fixed environments, frozen data and waiting for the page to settle.
  • Visual diffs always need a human decision: approve or fix.
  • Automate stable, high-value screens and keep a manual pass for exploration and accessibility.

Next up: Cloud Testing and AI in Testing.