docs(nodejs): extend geolocation context examples (#17587)

This commit is contained in:
Tim Deschryver 2022-10-31 17:39:44 +01:00 committed by GitHub
parent a7f5f2d7a1
commit cb1dcccbe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -553,7 +553,35 @@ await using var context = await browser.NewContextAsync(new()
Change the location later:
```js
```js tab=js-ts
import { test, expect } from '@playwright/test';
test.use({
geolocation: { longitude: 48.858455, latitude: 2.294474 },
permissions: ['geolocation'],
});
test('my test with geolocation', async ({ page, context }) => {
// overwrite the location for this test
context.setGeolocation({ longitude: 29.979097, latitude: 31.134256 });
});
```
```js tab=js-js
const { test, expect } = require('@playwright/test');
test.use({
geolocation: { longitude: 48.858455, latitude: 2.294474 },
permissions: ['geolocation'],
});
test('my test with geolocation', async ({ page, context }) => {
// overwrite the location for this test
context.setGeolocation({ longitude: 29.979097, latitude: 31.134256 });
});
```
```js tab=js-library
await context.setGeolocation({ longitude: 29.979097, latitude: 31.134256 });
```