From cb1dcccbe6def06a6d55c5e28e7223daf68befdb Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Mon, 31 Oct 2022 17:39:44 +0100 Subject: [PATCH] docs(nodejs): extend geolocation context examples (#17587) --- docs/src/emulation.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/src/emulation.md b/docs/src/emulation.md index 12b7a9d6f0..fab9d3c961 100644 --- a/docs/src/emulation.md +++ b/docs/src/emulation.md @@ -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 }); ```