## TL;DR

Set the geolocation coordinates and grant the geolocation permission when the browser context is created; granting permission after the page is open is too late. Both options belong in the same newContext call.

## The query

```text
playwright geolocation not applied in test: how to fix
```

## Use this when

- the page ignores mocked coordinates
- a permission prompt appears despite grants
- location tests flake

## Not for

- IP-based geolocation
- timezone mocking (a separate option)
- real-device GPS

## Steps

1. Move geolocation into context creation: browser.newContext with geolocation coordinates and permissions ['geolocation'] together. Expected output: one newContext call carries both options.
2. Remove any later permission grants for geolocation in the test. Expected output: no grantPermissions call for geolocation after page creation.
3. Have the page query its geolocation and assert the returned coordinates. Expected output: the coordinates match what the context was given.
4. If tests share a context, give geolocation tests their own context so coordinates do not bleed across tests. Expected output: each geolocation test creates a fresh context.
5. Re-run and confirm the app behaves as if at the mocked location. Expected output: location-dependent UI shows the mocked area.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_I7GyRPm4RzEIPlxW8OfddQ
