Sub topic 3
Setting up a fair comparison
A visual QA pass only works if the page and the design are measured under the same conditions. Many "bugs" reported in QA come from a mismatch in setup, not from the code. This chapter covers how to prepare the browser, the viewport, zoom and pixel density, and the design reference, so that each difference you find is real.
This chapter assumes you know basic HTML and CSS (box model, selectors, units), can open browser DevTools, and can read a design file such as a Figma frame or a PDF spec. The measuring tools themselves are covered in the next chapter. Here we only prepare the ground.
Why setup decides the result
A comparison has two sides: the built page and the design. Both depend on variables you can control.
- Browser and version affect font rendering, default styles and layout rounding.
- Viewport width decides which CSS breakpoint applies.
- Zoom level scales every measurement.
- Device pixel ratio (DPR) changes how many physical pixels make up one CSS pixel.
- The design frame has its own width, scale and units.
If one of these differs between the two sides, a 16px gap can look like 20px, or a sharp icon can look blurry, without any defect in the build.
Step 1: Choose the design frame to compare against
Designs usually contain several frames, one per breakpoint, such as mobile at 375px, tablet at 768px and desktop at 1280px or 1440px. Pick the frame that matches the width you will test.
Check these things in the design file first:
- The frame width in pixels. Write it down.
- The scale. Some exports are 2x, so a 750px image is a 375px design.
- The design status. Confirm that the frame is marked as ready or approved, not a draft.
- The units. Design tools use pixels, while the CSS may use
rem,%orclamp().
If a frame for a given width does not exist, you cannot make a pixel comparison at that width. Note it, and ask the designer how the layout should behave there. Do not guess.
Step 2: Fix the browser and its state
Use one primary browser for the main pass. Chrome or Firefox are common choices because their DevTools are strong. Cross-browser checks come later in the tutorial.
Remove noise from the browser before you start:
- Use a clean profile or a private window, so extensions do not inject styles or change fonts. Dark-mode extensions and ad blockers are frequent causes of false differences.
- Reset the zoom to 100% with
Ctrl+0(orCmd+0on macOS). - Check that the browser's default font size has not been changed in settings. A changed default affects every
remvalue. - Make sure the page is not cached from an old build. Do a hard reload, or tick "Disable cache" in the DevTools Network panel while DevTools is open.
- Confirm that you are looking at the right environment, such as staging, and the right build.
Step 3: Set the viewport precisely
The viewport is the visible area of the page, measured in CSS pixels. Dragging the window edge gives you imprecise widths. Use the device toolbar in DevTools instead.
- Open DevTools and turn on the device toolbar (
Ctrl+Shift+MorCmd+Shift+M). - Choose "Responsive" and type the exact width and height, for example 1280 by 900.
- Keep the zoom of the toolbar at 100%.
Two details cause trouble here.
First, the scrollbar. On many desktop systems a vertical scrollbar takes about 15px from the viewport width. A window that is 1280px wide may have only 1265px for content. The DevTools device toolbar usually hides this, but a real window does not. Use the same method on every test, and note which one you used.
Second, the viewport height. Layouts that use 100vh or sticky headers depend on it. On mobile browsers the address bar also changes the visible height as you scroll. Record the height you tested.
Step 4: Understand pixel density
A CSS pixel is not always one physical pixel. The device pixel ratio (DPR) is the number of physical pixels per CSS pixel. A standard monitor has a DPR of 1. Many laptops and phones have a DPR of 2 or 3.
You can read it in the DevTools console:
console.log({
dpr: window.devicePixelRatio,
innerWidth: window.innerWidth,
innerHeight: window.innerHeight,
zoomAndDprCombined: window.devicePixelRatio
});Note that browser zoom changes devicePixelRatio. At 200% zoom on a DPR 1 screen the value is 2. This is why you check zoom first.
The practical rules are:
- Compare at the same DPR as the design export. A 2x design image compared with a DPR 1 screenshot will look blurry or doubled in size.
- Judge image sharpness on a DPR 2 display or with DPR emulation, because a 1x image looks fine at DPR 1 and soft at DPR 2.
- Measure layout in CSS pixels, not in screenshot pixels. A 32px gap on a DPR 2 screenshot is 64 image pixels wide.
| Situation | What you see | What to do |
|---|---|---|
| Design at 1x, screenshot at DPR 2 | Screenshot is twice the size | Scale to 50% or capture at DPR 1 |
| Design at 2x, screenshot at DPR 1 | Design is twice the size | Scale the design to 50% |
| Browser zoom at 110% | All sizes are 10% off | Reset zoom to 100% |
| Scrollbar present | Content is about 15px narrower | Match the scrollbar setting in both tests |
Step 5: Match fonts and content
Font and content differences produce the largest visual changes, so fix them before measuring.
- Confirm that the web fonts actually loaded. In DevTools, open the Network panel and filter by "Font". If a font failed, the browser shows a fallback with different widths, and every line may wrap differently.
- Wait for fonts before you capture anything. Text can shift when the font swaps in.
- Check that the text in the design is the real text. Designs often use placeholder copy. A headline that fits in the design but wraps in the build may simply be longer. Treat that as a content question, not a style bug.
- Make sure images and data match, or note where they cannot.
Step 6: Write down the test conditions
Write the conditions at the top of your notes, so another person can repeat the pass and get the same result. A short record is enough.
const conditions = {
url: location.href,
browser: navigator.userAgent,
viewport: `${window.innerWidth}x${window.innerHeight}`,
dpr: window.devicePixelRatio,
rootFontSize: getComputedStyle(document.documentElement).fontSize,
fontsReady: document.fonts.status
};
console.table(conditions);The document.fonts.status value is "loaded" once all requested fonts are ready. If it shows "loading", wait and run it again.
Common mistakes
- Comparing a 1440px design with a 1280px window and calling the difference in margins a bug.
- Leaving browser zoom at 90% or 110% from earlier work.
- Testing with an extension that changes fonts or colors.
- Using a cached build, so you check fixes that are already made, or miss ones that are not deployed.
- Judging color on a screen with night mode or a different color profile. Turn off night shift features, and use the same display for the whole pass.
- Reading screenshot pixel measurements as CSS pixels when DPR is above 1.
Exercises
Exercise
You measure a card gap of 40px in a screenshot taken on a laptop. The design says 20px. The laptop has a DPR of 2. Is this a bug? Explain how you would confirm it.
Show answer
Probably not. At DPR 2 the screenshot has two image pixels for each CSS pixel, so 40 image pixels equal 20 CSS pixels, which matches the design. To confirm, read the gap in DevTools (computed margin or gap, which is in CSS pixels) or check window.devicePixelRatio and divide the screenshot measurement by it.
Exercise
A tester reports that the desktop navigation turns into the mobile menu on a 1280px-wide window, but the design shows the desktop version at 1280px. List three setup factors you would check before filing a bug.
Show answer
Check browser zoom (at 125% or more the viewport is narrower in CSS pixels, which can trigger the mobile breakpoint), the real viewport width including the scrollbar (read window.innerWidth), and the default browser font size or extensions that might change rem-based or em-based breakpoints. Also acceptable: confirm the build is the correct one and not cached.