playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Question] How do i block the location pop-up

Open harshith-aimyth opened this issue 2 years ago • 7 comments

Hi,

I want to block the location popup in my test function in playwright how do I do that?

image

test('Test123', async ({ page }) => {
        page.goto('google.com');
}

harshith-aimyth avatar Nov 21 '22 15:11 harshith-aimyth

https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions

jameskip avatar Nov 21 '22 18:11 jameskip

Also, here is a guide for geolocation.

dgozman avatar Nov 21 '22 23:11 dgozman

This will not block the geolocation. Is there a way I can block the location from playwright

harshith-aimyth avatar Nov 22 '22 12:11 harshith-aimyth

@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.

dgozman avatar Nov 22 '22 18:11 dgozman

Is it possible to deny this prompt at the context level by passing this: --deny-permission-prompts to chromium?

jameskip avatar Nov 26 '22 17:11 jameskip

@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'] },
      },
    }
  ],
};

dgozman avatar Nov 27 '22 23:11 dgozman

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? :)

Gal337 avatar May 23 '23 12:05 Gal337