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

How to catch a "Permission request" dialog event? #846

Closed
xfumihiro opened this issue Sep 21, 2017 · 16 comments
Closed

How to catch a "Permission request" dialog event? #846

xfumihiro opened this issue Sep 21, 2017 · 16 comments

Comments

@xfumihiro
Copy link

screen shot 2017-09-21 at 7 37 02 pm

@ebidel
Copy link
Contributor

ebidel commented Sep 24, 2017

There's a feature request upstream to add devtools protocol API sfor granting/denying these types of permissions: https://bugs.chromium.org/p/chromium/issues/detail?id=631464

In Lighthouse, we used to capture API calls that invoke the prompts. We used that to determine when prompts were being showed. However, there's no way to block/deny it programmatically.

@aslushnikov
Copy link
Contributor

@xfumihiro out of curiosity, what's your usage scenario for this?

@xfumihiro
Copy link
Author

@aslushnikov I was trying to catch if the "request permission" is issued on the auth/login flow. (Better UX - iff user asked for it 😃 )

@hotNoder
Copy link

@ebidel Hi, I have a question about the Notification. I use puppeteer to visit a site which alert the notification. If I don't close the notification manually, the program wouldn't go forward.
So there's no way to avoid the notification programmatically?

@ebidel
Copy link
Contributor

ebidel commented Oct 19, 2017

No there's not. That's the feature request in https://bugs.chromium.org/p/chromium/issues/detail?id=631464.

@saselovejulie
Copy link

i need geolocation permission... hope this will be release soon

@xfumihiro xfumihiro changed the title How to catch a "Show notifications" request dialog event? How to catch a "Permission request" dialog event? Oct 24, 2017
@CommanderXL
Copy link

@saselovejulie I try overwrite the method of getCurrentPosition, and it work well:

navigator.geolocation.getCurrentPosition = function (cb) {
  setTimeout(() => {
    cb({
      'coords': {
        accuracy: 21,
        altitude: null,
        altitudeAccuracy: null,
        heading:null,
        latitude: 23.129163,
        longitude: 113.264435,
        speed:null
      }
    })
  }, 1000)
}

@Skagoo
Copy link

Skagoo commented Mar 13, 2018

I personally suggest to use a custom user profile that has accepted te prompt before.
You could set this up by running chrome from the command line with the following argument:
--user-data-dir=/path/to/your/custom/profile

If the given profile path does not exist it will be created.

Now go to the website that requires you to accept this dialog, accept it manually and close the chrome window.
Now you automatically saved this choice in the custom profile.

Now it is as simple as using the custom profile for your chrome driver, again with the same argument:
--user-data-dir=/path/to/your/custom/profile

e.g. In C# Using a Chromedriver with ChromeOptions this would be:

ChromeOptions options = new ChromeOptions();
options.AddArgument("--user-data-dir=/path/to/your/custom/profile");
ChromeDriver driver = new ChromeDriver(options);

@ebidel
Copy link
Contributor

ebidel commented Apr 26, 2018

@aslushnikov are you tackling this from the protocol-side? We're getting more inbound requests for an API and it's an important one to have for testing lots of different APIs.

@aslushnikov
Copy link
Contributor

are you tackling this from the protocol-side?

@ebidel yeah, this is in my queue after the browser contexts.

@ralyodio
Copy link

ralyodio commented Jun 2, 2018

Any update on this? I'm doing some process of a large list of urls and it renders headless mode basically useless after 2 minutes of scraping if you encounter enough of these.

@andresilveirah
Copy link

andresilveirah commented Jun 3, 2018

Having the same issue. When launching with headless: false, Puppeteer gets stuck when asked for permission for notifications.

@ralyodio
Copy link

ralyodio commented Jun 3, 2018

Only way I found was to set headless to true.

@shmdhussain
Copy link

@aslushnikov @ebidel Is this feature available in Pupeeteer to allow or reject notification prompt?

If there is, I have one scenario, If you allow the automated browser to accept or deny the notification prompt, every time a new notification prompt is accepted uid is created and this will cause problems for the web sites who subscribed to the third party notification service where they are capped to limits for number of notifications UIDs

@andycaramba
Copy link

andycaramba commented Aug 14, 2018

Adding --disable-notifications to Pupeeteer launch() args works for me in relation to current issue. According to this link this argument Disables the Web Notification and the Push APIs. but it's ok for my purposes

aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Aug 28, 2018
This roll includes:
- https://crrev.com/584293 - DevTools: execute scripts in addScriptToEvaluateOnLoad in order
- https://crrev.com/585630 - DevTools: introduce Browser.grantPermissions

References puppeteer#846.
Fixes puppeteer#3106.
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Aug 29, 2018
This roll includes:
- https://crrev.com/584293 - DevTools: execute scripts in addScriptToEvaluateOnLoad in order
- https://crrev.com/585630 - DevTools: introduce Browser.grantPermissions
- https://crrev.com/587156 - Revert "[Base] Use background mode for ThreadPriority::BACKGROUND threads (behind feature) (reland)."

The "revert" patch fixes headless functionality on windows.

References puppeteer#846.
Fixes puppeteer#3106.
aslushnikov added a commit that referenced this issue Aug 30, 2018
This roll includes:
- https://crrev.com/584293 - DevTools: execute scripts in addScriptToEvaluateOnLoad in order
- https://crrev.com/585630 - DevTools: introduce Browser.grantPermissions
- https://crrev.com/587156 - Revert "[Base] Use background mode for ThreadPriority::BACKGROUND threads (behind feature) (reland)."

The "revert" patch fixes headless functionality on windows.

References #846.
Fixes #3106.
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Aug 30, 2018
Introduce an API to manage permissions per browser context:
- BrowserContext.overridePermissions(origin, permissions)
- BrowserContext.resetPermissionOverrides()

Fixes puppeteer#846.
aslushnikov added a commit that referenced this issue Aug 30, 2018
…3159)

Introduce an API to manage permissions per browser context:
- BrowserContext.overridePermissions(origin, permissions)
- BrowserContext.clearPermissionOverrides()

Fixes #846.
@0x11-dev
Copy link

You can permit geo location api via the new api introduced in v1.8.0. https://pptr.dev/#?product=Puppeteer&version=master&show=api-browsercontextoverridepermissionsorigin-permissions Y

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