Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
harshith-aimyth opened this issue Nov 21, 2022 · 8 comments
Closed

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

harshith-aimyth opened this issue Nov 21, 2022 · 8 comments

Comments

@harshith-aimyth
Copy link

harshith-aimyth commented Nov 21, 2022

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');
}
@jameskip
Copy link

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

@dgozman
Copy link
Contributor

dgozman commented Nov 21, 2022

Also, here is a guide for geolocation.

@harshith-aimyth
Copy link
Author

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

@dgozman
Copy link
Contributor

dgozman commented Nov 22, 2022

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

@jameskip
Copy link

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

@dgozman
Copy link
Contributor

dgozman commented Nov 27, 2022

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

@Gal337
Copy link

Gal337 commented May 23, 2023

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

@pavelfeldman
Copy link
Member

Why was this issue closed?

Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.

If you disagree with this closure, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants