Exit course
Chapter 10 of 11 Intermediate 6 min read 2 quick checks Updated

Visual Differences Between Browsers

On this page
  1. Look before you automate
  2. Expected differences and real bugs
  3. From looking to testing
  4. Summary

Functional tests answer "does it work?" in every browser. They do not answer "does it look right?" A button that is clickable but half-hidden behind a header, a font that falls back to something ugly, a layout that wraps into two columns in one browser only: all of those pass a functional test. This chapter shows what visual differences between browsers look like in practice, which of them matter, and where a dedicated visual testing workflow takes over.

Look before you automate#

The quickest way to see visual differences is to put screenshots side by side. The fixture from chapter 4 already opens one session per configuration, so a small test can save a screenshot from each:

from pathlib import Path

SHOTS = Path("shots")


def test_capture_form(driver, request):
    driver.set_window_size(1280, 900)
    driver.get("https://www.selenium.dev/selenium/web/web-form.html")
    SHOTS.mkdir(exist_ok=True)
    driver.save_screenshot(str(SHOTS / f"{request.node.callspec.id}.png"))
    label = driver.execute_script(
        "return getComputedStyle(document.body).fontFamily")
    print(request.node.callspec.id, "body font:", label)

On the smoke tier from chapter 7 it produced three files:

Configuration Screenshot size Visible differences on the same form
Chrome, Windows 11 1264 x 805 "Choose File / No file chosen", Segoe UI text
Firefox, Windows 11 1264 x 807 "Browse... / No file selected.", Segoe UI text
Safari, macOS Tahoe 1280 x 848 "Choose File / no file selected", San Francisco text, tighter line spacing

Every one of these is correct behaviour. The page asks for the system font (system-ui), which is Segoe UI on Windows and San Francisco on macOS. The file input's button and label are drawn by the browser, in its own words. The window is the same size in every session, but the area the page gets (and so the screenshot) depends on the browser's own toolbars and borders.

Even the printed font list differs in a way that would break a naive test: Chrome and Safari return "Segoe UI" with quotes, Firefox returns Segoe UI without. Comparing computed style strings across browsers is as fragile as comparing pixels.

TestingBot can also take this kind of side-by-side for you without code: the screenshot testing tool takes a URL and returns screenshots from the browsers you pick, which is a quick sanity check before a release.

You compare a Firefox screenshot of your page with a Chrome baseline and get a 4% pixel difference, mostly in text and in the file upload button. What does that tell you?

Text anti-aliasing, fonts and browser-drawn controls differ between browsers by design. Comparing across browsers drowns real regressions in expected noise. Compare each browser with its own earlier screenshot instead, and keep thresholds tight.

Expected differences and real bugs#

When you review cross-browser screenshots, sort what you see into two groups.

Expected, leave alone:

  • Font rendering and anti-aliasing, and the system font itself.
  • Browser-drawn controls: file inputs, date pickers, select arrows, range sliders, scrollbars.
  • A few pixels of difference in line height or text width, as long as nothing wraps differently or overflows.

Real bugs, worth a ticket:

  • Text that wraps, overflows or is cut off in one browser, usually because a width was designed to the pixel with one font.
  • Elements that overlap or disappear, often a flexbox or grid feature that one engine handles differently or does not support in an older version you still have in the matrix.
  • Missing images or icons, for example an image format or font file one browser cannot load.
  • A different layout at the same viewport width, usually a media query that depends on the scrollbar or on a feature query (@supports) that resolves differently.

The rule of thumb: if a user would notice and care, it is a bug; if only a pixel diff would notice, it is an engine difference.

Which of these is most likely a real cross-browser bug rather than an expected difference?

Wrapped navigation that covers content is visible and harmful to users, typically caused by a width that only fits with one font. Control labels and font smoothing are drawn by the browser and OS and differ by design.

From looking to testing#

Eyeballing screenshots does not scale beyond a handful of pages. Automated visual testing does the comparison for you, and it follows the rule from the quiz above: one baseline per browser. Each configuration is compared only with its own earlier screenshots, so the expected differences never show up, and a change that breaks the layout in one browser does.

The Visual Regression Testing course covers that workflow end to end, so this course does not repeat it. The chapters most relevant here are:

Two practical points carry over from this course into visual testing:

  • Baselines must come from the same environment they are compared in. A baseline taken on your Mac and compared in Linux CI fails on every text pixel. Take baselines on the grid configuration that runs the comparison.
  • Keep visual tests to the pages that matter. A visual check on every page in every browser multiplies review work. Start with the pages where a broken layout costs money: the landing page, sign-up, checkout.

Summary#

  • Side-by-side screenshots show cross-browser differences quickly; the same window size still gives different page areas.
  • Fonts, anti-aliasing and browser-drawn controls differ by design; wrapping, overlap and missing content are bugs.
  • Never compare one browser's screenshot with another's; give each browser its own baseline.
  • For the full visual testing workflow, continue with the Visual Regression Testing course.