Sub topic 11
Testing navigation on real devices
Navigation is the part of a site that every visitor touches first. A menu that works in a resized desktop browser can still fail on a phone, because browser devtools don't reproduce touch hardware, browser toolbars, or screen readers. This chapter gives you a test routine for the hamburger menu, the tab bar, and the priority menu from the earlier chapters.
It assumes you have built at least one of those patterns, that you can read a short Playwright test, and that you know what aria-expanded and aria-current do.
What emulation can and cannot tell you
Device mode in Chrome or Firefox resizes the viewport, sets a touch-like pointer, and sends a mobile user agent. That is enough to check breakpoints and basic layout. It does not reproduce several things that break navigation:
- The browser chrome. On iOS Safari the address bar and bottom toolbar change size as you scroll. A fixed bottom tab bar can sit under them or jump.
- Safe areas. The home indicator and rounded corners only exist on real hardware, or in a simulator that models them.
- Real touch behavior. This includes finger-sized contact areas, accidental taps near edges, and the delay or ghost-click behavior of older browsers.
- Screen readers. VoiceOver and TalkBack expose navigation differently from a desktop screen reader, and they are what most mobile users with vision loss use.
- Performance. A menu animation that is smooth on your laptop may stutter on a budget phone.
Treat emulation as the fast first pass and real devices as the check that decides whether you ship.
Build a device matrix
You cannot own every phone. Choose a small set that covers the different rendering engines and input behaviors.
| Device or setup | Why it is in the set |
|---|---|
| Recent iPhone with Safari | WebKit engine, dynamic toolbars, safe areas, VoiceOver |
| Small or older iPhone | Narrowest common width and the least vertical space |
| Mid-range Android with Chrome | Blink engine, TalkBack, slower CPU |
| Android with Firefox or Samsung Internet | Different default behaviors for zoom and text size |
| Tablet in portrait and landscape | Sits between your mobile and desktop breakpoints |
| Phone or tablet with an external keyboard | Checks Tab, Enter, Space, and Escape on a touch device |
Check your analytics for the browsers your visitors use, and weight the set toward them. If you can't buy devices, a cloud device service or the iOS Simulator and Android Emulator will cover layout and most behavior. They won't cover real performance or the feel of touch.
Reach your dev server from a phone
Serve the site on your local network and open it from the phone on the same Wi-Fi. Most dev servers accept a host option, for example npx vite --host or python3 -m http.server 8080 --bind 0.0.0.0. Then browse to your computer's local IP address, such as http://192.168.1.20:8080.
Connect remote debugging so you can inspect the real page:
- Android with Chrome. Turn on USB debugging, plug the phone in, and open
chrome://inspecton the desktop. You get the full DevTools for the phone's tab. - iPhone with Safari. Turn on Web Inspector under Settings, Safari, Advanced. Enable the Develop menu in desktop Safari, then choose your device from it.
Remote debugging lets you read console errors from your toggle script and inspect computed styles, such as the value of env(safe-area-inset-bottom) on the tab bar.
Automate the checks that never change
Some behavior is the same on every run, so a script should check it. A script catches regressions like a lost aria-expanded update, which would otherwise surface months later. This Playwright test covers the hamburger menu from the earlier chapters. It assumes the page is served at http://localhost:8080/.
import { test, expect } from '@playwright/test';
test.use({
baseURL: 'http://localhost:8080',
viewport: { width: 375, height: 667 },
hasTouch: true,
});
test('menu opens by tap, closes with Escape, and returns focus', async ({ page }) => {
await page.goto('/');
const toggle = page.locator('#menu-toggle');
const menu = page.locator('#site-menu');
await expect(toggle).toHaveAttribute('aria-expanded', 'false');
await expect(menu).toBeHidden();
await toggle.tap();
await expect(toggle).toHaveAttribute('aria-expanded', 'true');
await expect(menu).toBeVisible();
await page.keyboard.press('Escape');
await expect(toggle).toHaveAttribute('aria-expanded', 'false');
await expect(menu).toBeHidden();
await expect(toggle).toBeFocused();
});
test('menu links are at least 44px tall', async ({ page }) => {
await page.goto('/');
await page.locator('#menu-toggle').tap();
const links = await page.locator('#site-menu a').all();
expect(links.length).toBeGreaterThan(0);
for (const link of links) {
const box = await link.boundingBox();
expect(box.height).toBeGreaterThanOrEqual(44);
}
});The second test uses 44px as the floor. WCAG 2.2 requires at least 24 by 24 CSS pixels (success criterion 2.5.8). The stricter 44 by 44 target size recommendation comes from WCAG 2.1 (2.5.5) and Apple's guidelines. The 48px minimum height used for the tab bar is above that line, and Material Design uses a similar 48dp target.
You can also run an automated accessibility scanner such as axe-core against the page, both with the menu closed and with it open. Scanners catch missing names, bad ARIA attribute values, and contrast failures. They cannot tell you whether the focus order makes sense or whether the page announces itself clearly. That is what the manual passes are for.
The keyboard pass
Do this on desktop first, with the browser narrowed below your breakpoint and the mouse unplugged in spirit. On desktop Safari, Tab skips links by default. Use Option+Tab, or turn on "Press Tab to highlight each item on a webpage" in Safari's settings.
For the hamburger menu, walk through this list:
- Tab reaches the Menu button, and a visible focus ring appears.
- Enter and Space both open the menu. A native
buttondoes this for free. If you built the toggle from adiv, this is where you'll notice. - After opening, Tab moves into the first link in the list.
- Escape closes the menu and focus lands back on the toggle.
- With the menu closed, Tab skips the hidden links. The
hiddenattribute removes them from the tab order. - Widening the window past the breakpoint shows the full list and hides the button, with no stranded focus.
For the tab bar, check that Tab visits each link once, in visual order, and that the focused link is not hidden behind the bar. A fixed bar can cover the focused element when the page scrolls. If you see this, add scroll padding to the page, for example scroll-padding-bottom: 4rem on html, so focused content scrolls clear of the bar.
For the priority menu, check that links moved into More still work with the keyboard. Open the details element with Enter or Space, then Tab through its links. The tab order should stay in the same sequence the links had in the bar.
The screen reader pass
Turn on a screen reader and navigate without looking at the screen. Test at least VoiceOver on iOS and TalkBack on Android, plus one desktop reader such as NVDA or VoiceOver on macOS.
- VoiceOver on iOS. Turn it on in Settings, Accessibility, VoiceOver. Setting the Accessibility Shortcut to VoiceOver lets you toggle it with a triple-click of the side button. Swipe right and left to move through elements and double-tap to activate.
- TalkBack on Android. Turn it on in Settings, Accessibility. Swipe the same way and double-tap to activate.
Listen for these specifics:
- The toggle is announced as a button, with its name and its state: "Menu, button, collapsed", then "expanded" after activation.
- The navigation is announced as a landmark with its label, such as "Main, navigation". If you have both a tab bar labeled "Primary" and a header menu labeled "Main", each should be announced distinctly.
- The current tab announces "current page" because of
aria-current="page". - Hidden links are not read while the menu is closed.
- Inside More, the
summaryis announced as a button or disclosure with its expanded state.
Also use the rotor on iOS, or the Local Context menu on TalkBack, to list landmarks. If the nav doesn't appear, the markup is not semantic enough.
The real device pass
With keyboard and screen reader behavior confirmed, hold the phone. Work through each pattern with these questions.
Touch and reach
- Can you tap every item with your thumb while holding the phone one-handed, without hitting a neighbor?
- Does the Menu button sit where your thumb reaches, or at the top corner where it needs a grip change?
- Is there enough space between adjacent targets? Two 48px targets with no gap are fine. Two 24px targets with no gap are not.
Browser chrome and safe areas
- Scroll up and down on iOS Safari. Does the tab bar stay visible and clear of the home indicator? Safe-area padding only works when the viewport meta tag includes
viewport-fit=cover, so confirm that tag is present and thatenv(safe-area-inset-bottom)is nonzero in remote debugging. - Rotate to landscape. On a notched iPhone, content must not hide under the notch, and a tab bar that takes 48px from a 320px-tall screen leaves little room for content. Consider whether the bar should be shorter in landscape.
- Open the on-screen keyboard in a search field. Some browsers shrink the visual viewport and push a fixed bottom bar up over the field. If that happens, hide the tab bar while an input has focus.
Text size and zoom
- Raise the system font size on both platforms and reload. A priority menu measures widths at run time, so larger text should push more links into More, not clip them.
- Pinch-zoom to 200 percent. Navigation must stay usable, which means the viewport tag must not disable zoom.
- Check that labels do not truncate in other languages. German or Finnish labels are often much longer than English ones.
Performance and stability
- Open and close the menu repeatedly. It should respond on the first tap, with no visible delay.
- Reload the page on a slow connection and watch for layout shift. A priority menu that renders all links, then collapses them, can flash. A
visibility: hiddenrule until the firstupdate()finishes avoids that. - Check the back button. Opening the menu and pressing back should not leave the site unexpectedly if you did not add history entries on purpose.
Cross-pattern checks
If you combine patterns across breakpoints, as in the previous chapter, test the seams. Resize slowly from 320px up to 1280px and stop at every change. At each width, exactly one primary navigation should be visible, and its landmark should be the only one with that label. Test the exact breakpoint widths and one pixel either side. Rotating a tablet crosses a breakpoint without a page reload, so check that the open or closed menu state survives sensibly and that no stale aria-expanded="true" remains on a hidden toggle.
Common mistakes
- Testing only in a narrowed desktop window and never on a phone.
- Checking with the mouse and never pressing Tab.
- Testing with the menu closed only. Open states carry most of the bugs.
- Treating a clean axe report as proof of accessibility.
- Testing only the newest phone. The smallest and oldest device in your set shows overflow first.
Exercise
Your tab bar looks perfect in Chrome device mode, but on an iPhone the bottom of the labels is cut off by the home indicator. Give two things to check and the fix.
Show answer
First check that the viewport meta tag includes viewport-fit=cover, because without it env(safe-area-inset-bottom) resolves to 0. Second, check that the tab bar has padding-bottom: env(safe-area-inset-bottom). Fix by adding viewport-fit=cover to the meta tag (width=device-width, initial-scale=1, viewport-fit=cover) and keeping the padding rule. Then confirm the value on the real device through remote debugging.
Exercise
A screen reader user opens your hamburger menu with a double-tap, but VoiceOver announces only "Menu, button" and never says the menu is open. What is the likely cause, and how would you write a Playwright assertion to prevent it from returning?
Show answer
The toggle probably does not update aria-expanded when clicked, or it never had the attribute. Without it, the button gives no state. Prevent the regression with await toggle.tap(); await expect(toggle).toHaveAttribute('aria-expanded', 'true');, and after closing, an assertion for 'false'.