Overview
Browser contexts provide isolated browser environments. This guide covers advanced context features like permissions, geolocation, timezone emulation, offline mode, and more.Permissions
Grant or deny browser permissions for specific origins to test permission-dependent features.Available Permissions
geolocation
geolocation
Allow access to device location.
midi
midi
Allow access to MIDI devices.
notifications
notifications
Allow showing notifications.
camera
camera
Allow access to camera.
microphone
microphone
Allow access to microphone.
clipboard-read
clipboard-read
Allow reading from clipboard.
clipboard-write
clipboard-write
Allow writing to clipboard.
payment-handler
payment-handler
Allow registering payment handlers.
Geolocation
Emulate device geolocation to test location-based features.Offline Mode
Simulate offline network conditions to test application behavior without connectivity.Offline Mode
Timezone Emulation
Emulate different timezones to test time-sensitive features.Timezone Configuration
Locale and Language
Emulate different locales and languages for internationalization testing.HTTP Authentication
Provide HTTP authentication credentials for protected resources.HTTP Credentials
Extra HTTP Headers
Add custom HTTP headers to all requests in the context.Custom Headers
Storage State
Save and restore browser context state including cookies and local storage.Service Workers
Access and interact with service workers in the context.Service Workers
Best Practices
Isolation
Use separate contexts for tests requiring different browser states. Each context is completely isolated.
Performance
Reuse contexts when possible, but create new ones when state needs to be reset completely.
Permissions
Always grant necessary permissions before navigating to pages that require them.
Cleanup
Contexts are automatically closed, but explicitly close them when done for clarity.
Related Resources
Browser Context Basics
Learn the fundamentals of browser contexts
Authentication
Advanced authentication patterns
