Protractor: Protractor Chrome Allow Notifications

Created on 22 Oct 2015  Â·  17Comments  Â·  Source: angular/protractor

Chrome just auto-updated to version 46. I am trying to run my protractor tests but I always get the Allow Notifications pop-up now. Does anyone know how to get around this? How I can make it always allow notifications for my tests?

allownotifications

Is there a chrome option or something that we can set in the config file?

Most helpful comment

@sjelin and @rfodge I got it to work with

prefs: {'profile.managed_default_content_settings.geolocation': 1}

@rfodge the value should 0, 1, 2, 3 ...
Give it shot.

All 17 comments

Not sure about this, but could you use browser.switchTo().alert().accept() to accept the notification?

Thanks for the suggestion - I tried that but didn't work.

I have similar issue with geo location popup. I don't think that the approach will work because it is browser native alert. I haven't found a solution yet either. It seems to be a problem for new Chrome browser 46 or the latest chrome driver. I already set it in browser setting to accept all sites for geo location. New browser from protractor only takes default setting where I have to click to accept.

screen shot 2015-10-22 at 4 19 13 pm

Yeah, I tried searching for a Chrome Option to set it to allow via the protractor config file but I couldn't find one. However, to get around it for now, I was able to run Chrome in incognito mode via an option and that must always allow notifications. Maybe you could try that as well as a workaround for now until someone else lets us know of a solution?

image

I try to run in incognito mode but geo location popup is there for me :(

On Thu, Oct 22, 2015 at 4:52 PM, rfodge [email protected] wrote:

Yeah, I tried searching for a Chrome Option to set it to allow via the
protractor config file but I couldn't find one. However, to get around it
for now, I was able to run Chrome in incognito mode via an option and that
must always allow notifications. Maybe you could try that as well as a
workaround for now until someone else lets us know of a solution?

[image: image]
https://cloud.githubusercontent.com/assets/11653643/10677937/467b5f24-78dd-11e5-8865-f8c6b7389059.png

—
Reply to this email directly or view it on GitHub
https://github.com/angular/protractor/issues/2626#issuecomment-150352861
.

This is definitely possible via chromeOptions using perfs. I've looked at my preferences files and the memory of which sites I've enabled geolocation for is definitely there. It's a huge file though so exactly what to include in your config I'm not sure, but I know the option exists. Hope that helps!

Why did you close this issue, it wasn't resolved yet? we still dont know how or which chromeOptions to use. I still would like to know which options to use for notifications, if one exists.

So I found the prefs options here: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup

But i'm not sure what the value is i am supposed to use for the option? I tried this but it still doesn't work:
image

I closed the issue because GitHub issues are only for feature requests/bug reports/things that will induce use to change the codebase. Since these feature exists, it's more of a support question, which is better asked on stack overflow. Probably if you ask there there's a much better chance of someone knowing which option to use.

@sjelin and @rfodge I got it to work with

prefs: {'profile.managed_default_content_settings.geolocation': 1}

@rfodge the value should 0, 1, 2, 3 ...
Give it shot.

Yes, thank you! I got it to work with using 1 as well.

Could anyone please suggest how to allow or block location using the popup in protractor?

Hi, thanks for the info @rfodge ! but I need to allow navigator.webkitPersistentStorage and I can't find the pref name here:
http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc

someone know it?

Hi, what is the behaviour in headless chrome for Allow notification pop up?

How to handle app notification (Allow or Block) in progressive web app ( android-chrome browser)

Tried prefs: {'profile.managed_default_content_settings.geolocation': 1}
but it is not working.

Using protractor.

How to handle app notification (Allow or Block) android-chrome browser

Tried prefs: {'profile.managed_default_content_settings.notifications': 1}
but it is not working.

Using protractor.
Note: same works in desktop chrome

Was this page helpful?
0 / 5 - 0 ratings