playwright
playwright copied to clipboard
[Question] How do i block the location pop-up
Hi,
I want to block the location popup in my test function in playwright how do I do that?

test('Test123', async ({ page }) => {
page.goto('google.com');
}
https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions
Also, here is a guide for geolocation.
This will not block the geolocation. Is there a way I can block the location from playwright
@harshith-aimyth Oh, sorry, I misunderstood. So you'd like not to Allow, but to Block with Playwright? This is not supported today. I'll leave this as a feature request.
Is it possible to deny this prompt at the context level by passing this: --deny-permission-prompts to chromium?
@jameskip --deny-permission-prompts chromium flag works across all contexts, but Playwright will take that into account if you specify launchOptions.args for a single file:
test.use({ launchOptions: { args: ['--deny-permission-prompts'] } });
test('no prompts', async ({ page }) => {
});
Alternatively, just specify it once in the config to disable all prompts in all tests:
export default {
projects: [
{
name: 'chromium',
use: {
..devices['Desktop Chromium'],
launchOptions: { args: ['--deny-permission-prompts'] },
},
}
],
};
Hi, any news about Block function for geolocation? I was also looking on how to block it but seeing here, this option is still not supported or wasn't? :)