Sub topic 13
Testing with device emulation and real devices
This chapter assumes you can build a single-column layout with min-width media queries and open your browser's developer tools. It covers how to check a mobile-first page in an emulator, where emulation falls short, and how to run a short test loop on real phones.
What emulation shows you
Every major desktop browser has a device mode in its developer tools. It resizes the viewport, sets the device pixel ratio, and sends a mobile user agent string. It can also simulate touch input and throttle the network.
Use it to answer layout questions quickly:
- Does the single-column base layout fit without horizontal scrolling at 320 px wide?
- Does each min-width query change the layout where you expect?
- Do images and text stay inside their containers?
To find content-driven breakpoints, open device mode in responsive mode, which shows a freely resizable viewport. Drag the edge slowly from narrow to wide. When a line length becomes too long or a gap looks awkward, you have found a breakpoint. Device presets such as "iPhone" or "Pixel" are useful for a quick check, but they are not a list of sizes to design for.
What emulation cannot show you
Emulation runs on your desktop browser engine and your desktop hardware. It does not reproduce several things:
- Real touch behaviour. A mouse pointer is precise, and a thumb is not. You cannot judge tap comfort or reach with a cursor.
- Real performance. Your laptop CPU is much faster than a mid-range phone. Throttling approximates this but does not match it.
- Browser differences. Mobile Safari and Chrome on Android handle some features differently, such as dynamic toolbars that change the viewport height.
- Real conditions. Sunlight, screen brightness, system font settings, and a flaky network are missing.
A test loop for each change
The diagram shows a loop that keeps emulation for speed and uses real devices for confirmation.
Work through these checks in order:
- Set the viewport to 320 px wide and scroll the whole page. Look for horizontal scrolling, clipped text, and overlapping elements.
- Increase the width slowly. Confirm each breakpoint changes the layout cleanly and nothing breaks between breakpoints.
- Turn on network throttling (for example, a "Fast 4G" or "Slow 4G" profile) and reload with the cache disabled. Check that the most important content appears first, and that images do not shift the layout as they load.
- Check the images panel or network panel to confirm the browser picked a small file from
srcsetat narrow widths. - Turn on CPU throttling and use the page. Menus and
detailselements should still respond promptly. - Open the page on at least one real phone.
Testing on real devices
You do not need a device lab. One recent phone and one older, cheaper one cover most of what you will find. If you have only one, make it an Android phone or iPhone you do not usually use, or ask a colleague to lend one.
To load your local site on a phone, connect it to the same Wi-Fi network as your computer and open your computer's local network address and port in the phone's browser. Chrome and Safari also support remote debugging, where you connect the phone by USB and inspect the page in desktop developer tools while it runs on the phone.
On the device, check these things:
- Can you tap every link and button without hitting its neighbour?
- Can you reach the main navigation with one thumb?
- Is body text readable without zooming?
- Does rotating the phone to landscape break the layout?
- Does increasing the system font size still leave the page usable?
Also test with the browser's zoom or text size increased. A page built with rem units should scale. A page that uses fixed pixel sizes will not.
Recording what you find
Keep a short list of failures with the width or device where each appeared, and what fixed it. A fix is rarely a new device-specific rule. Usually it is a change to the base styles, such as allowing text to wrap or giving an image max-inline-size: 100%. Repeating the loop after each fix confirms that the change did not break another width.
Exercise
Your page looks perfect in browser device mode, but on a real phone the navigation links are hard to tap accurately. Why did emulation miss this, and what do you check and change?
Show answer
Emulation uses a mouse pointer, which is precise, so it hides how large a fingertip is. On the phone, check the size and spacing of the links. Give each link a minimum size of about 44 CSS pixels, for example with min-block-size and min-inline-size, and add padding or gaps so neighbouring links are not touching. Then retest on the phone.
Exercise
Name two checks you can do reliably in device emulation and two that need a real device.
Show answer
Reliable in emulation: checking for horizontal scrolling at 320 px wide, and finding where the layout breaks by resizing the viewport. Needs a real device: judging touch comfort and thumb reach, and measuring true performance on a mid-range phone's CPU and network.