Created
February 2, 2021 07:07
-
-
Save ankitsadariya/fd8607933c9313e77f62056b4159e1ec to your computer and use it in GitHub Desktop.
set geolocation for website using puppeteer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({ devtools: true }); | |
const page = await browser.newPage(); | |
// Grants permission for changing geolocation | |
const context = browser.defaultBrowserContext(); | |
await context.overridePermissions('https://www.google.com/', ['geolocation']); | |
await page.goto('https://www.google.com/'); | |
await page.waitForSelector('title'); | |
// Changes to the north pole's location | |
await page.setGeolocation({ latitude: 90, longitude: 0 }); | |
//await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment