Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsFor new Puppeteer code, set permissions on the page’s BrowserContext with context.setPermission(). The older overridePermissions() method is deprecated. To let a page read its geolocation, grant the geolocation permission for its origin, then set coordinates on the page.
Set a permission on the page’s browser context
Call setPermission() on the BrowserContext that owns the page. Pass the target origin and a permission descriptor with its state. This geolocation example follows the API shape documented in Puppeteer 25.12.0; supported descriptor names can depend on your installed Puppeteer and browser versions.
As an Amazon Associate I earn from qualifying purchases.
const context = browser.defaultBrowserContext();
await context.setPermission('https://example.com', {
permission: 'geolocation',
state: 'granted',
});
const page = await context.newPage();
For an isolated context, use that context instead of the default one. Pages expose their owning context through page.browserContext(), which is useful when configuring a page that already exists.
const context = page.browserContext();
await context.setPermission('https://example.com', {
permission: 'geolocation',
state: 'granted',
});
The method accepts an origin or '*' and one or more permission descriptor/state objects. Prefer a specific origin when the test only needs to affect one site.
#1 Best Overall
Granting geolocation also requires coordinates
Permission alone does not supply a location. Set the page’s geolocation after granting permission:
await context.setPermission('https://example.com', {
permission: 'geolocation',
state: 'granted',
});
await page.setGeolocation({ latitude: 37.7749, longitude: -122.4194 });
Puppeteer’s Page reference advises granting geolocation permission for the page to read the coordinates. Choose coordinates appropriate to the test; the example uses San Francisco.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
How the deprecated method differs
Older examples use overridePermissions() with a list of permission names:
await context.overridePermissions('https://example.com', ['geolocation']);
The current API reference marks this method deprecated in favor of setPermission(). Its documented behavior is also broader: it grants the listed permissions for the origin and automatically denies permissions omitted from the list. Do not treat it as equivalent to setting a single descriptor with setPermission().
Rank #3
| Method | Status in the current reference | Arguments and documented effect |
|---|---|---|
setPermission() |
Current approach | Origin (or '*') and permission descriptor/state object(s); sets permission state for the origin. |
overridePermissions() |
Deprecated | Origin and permission-name list; grants listed permissions and automatically denies unlisted ones. |
Clear permission overrides after a test
Use clearPermissionOverrides() to clear all permission overrides for a context:
await context.clearPermissionOverrides();
This clears overrides for the entire context, not just one permission or origin. Avoid calling it while other pages or tests sharing that context still depend on an override. Browser contexts isolate storage; the default context cannot be closed, while dedicated contexts can be closed when finished.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Common problems and fixes
- The page still asks for permission: Confirm that you set the permission on the same context that owns the page and used the page’s origin, including the correct scheme and host.
- Geolocation is granted but no location is available: Granting permission does not set coordinates; call
page.setGeolocation()as well. - A permission descriptor is rejected or has no effect: Verify the descriptor name against the Puppeteer and browser versions installed in your environment. The API shape does not guarantee every browser version supports every permission descriptor.
- A later test unexpectedly loses its setting: Check whether another test called
clearPermissionOverrides()on the shared context; it clears all overrides there. - Legacy code behaves differently after migration: Review omitted permissions. The deprecated method automatically denies permissions not listed, a behavior not to assume when replacing it with individual
setPermission()calls.
Or skip the browser setup
If the goal is simply to capture a website rather than test its browser permission behavior, ScreenshotNeo provides a screenshot API and MCP server. For example, this cURL request captures a page as WebP:
Quick Recap
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners are accepted and removed, along with known consent platforms, newsletter popups and chat widgets, before capture; those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server includes tools for AI agents to take screenshots, get page information and capture PDFs. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




