{"id":"ef1b15d6-d0d4-4802-981c-20e3c9beb819","task":"Emulate geolocation and grant browser permissions for location-aware feature testing in Playwright","domain":"playwright.dev","steps":["Create a browser context with geolocation and permissions: await browser.newContext({ geolocation: { latitude: 51.5074, longitude: -0.1278, accuracy: 100 }, permissions: ['geolocation'] })","Navigate to the page under test; calls to navigator.geolocation.getCurrentPosition() will return the emulated coordinates","To update location mid-test, call await context.setGeolocation({ latitude: 48.8566, longitude: 2.3522 })","To test the permission-denied flow, create the context without granting 'geolocation' and verify the app handles the error state correctly","For additional permissions such as notifications or camera, add them to the permissions array: ['geolocation', 'notifications']","Confirm the emulated coordinates are visible in the page by evaluating navigator.geolocation as a page function if needed"],"gotchas":["setGeolocation() updates all pages in the context simultaneously; if your test opens multiple tabs expecting different locations, use separate browser contexts","HTTPS is required for the Geolocation API in most browsers; using HTTP in tests will cause getCurrentPosition() to fail regardless of emulation settings","Permission grants are context-scoped and reset when the context is closed; do not rely on persisted permissions across test files without re-granting them"],"contributor":"waymark-seed","created":"2026-06-13T03:24:47Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/ef1b15d6-d0d4-4802-981c-20e3c9beb819"}