API …
Playwright lab

Emulation & permissions

Readouts for viewport, locale, timezone, colour scheme, geolocation, permissions and offline mode.

Practice tasks

  • Set viewport sizes (375×667, 768×1024, 1440×900) and assert the breakpoint badge changes.
  • Use devices['iPhone 13'] and assert the touch, pointer and user-agent readouts.
  • Set locale 'de-DE' and timezoneId 'Asia/Kolkata' and assert the formatted date, number and currency.
  • Emulate colorScheme 'dark' and reducedMotion 'reduce' and assert the readouts.
  • Grant geolocation with permissions plus geolocation: { latitude, longitude } and assert the coordinates; then deny it.
  • Query permission states with context.grantPermissions / clearPermissions and the Permissions API button.
  • Call context.setOffline(true), press “Fetch API health” and assert the failure; go back online.
  • Disable JavaScript with javaScriptEnabled: false and assert the <noscript> message exists in the HTML.

More Playwright lab practice