Handelling Notifications Popup Using Selenium WebDriver



Handling Notifications Popup in Selenium WebDriver



Nowadays we see observe that in most of the website there are various type of notifications popup coming which ask user permission to push/show some notifications, popup asking for user Geo Location, etc.

so in this article, we would check how to handle below type of browser notifications.

v Push Notifications
v Geo Locations
v Chrome Automation InfoBar




For Handling this type of popup, we need to make use of chrome options class for chrome Browser.

What is Chrome Options Class?

Chrome Options class is used to manage options specific to ChromeDriver. Chrome options class is generally used in along with Desired Capabilities.

For using Chrome Options, we need to create the instance of ChromeOptions to set ChromeDriver specific capabilities and then pass the ChromeOptions object to the WebDriver/RemoteWebDriver constructor.

How to handle Push Notifications Popups

For Demo purpose, I am using the website https://www.redbus.in which shows push notification like below on its home page.

Push Notification Popup


For Handling this we can use chrome options as “ --disable-notifications
Which will handle all the push notifications popups coming on its home page.

The complete Code snippet is given below






How to handle Geo Location Popup

In most of the applications, we see that popup a message asking user Geolocation is displayed like below.

Image result for google wants to know your location
Geo Location Popup

For Handling this we can use chrome options as “disable-geolocation
Which will handle all the location popup coming on the web-page.

The complete Code snippet is given below



How to handle Chrome Automation InfoBar

When Chrome browser is launched using selenium, We can see an info bar with message 'Chrome is being controlled by automated test software' like below.

Chrome Automation InfoBar


If we want to hide this info bar, we have to pass "disable-infobars" argument to ChromeOptions.

Below is the complete code snippet.




SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
Pratik
January 28, 2020 at 6:09 PM

i want to click on allow for the location popup ..how should i do that? please help

Reply
avatar
May 1, 2020 at 9:16 PM

Thank you Anuku jain, Your blog is help many Automation engineers Once again Thank you so much.

Reply
avatar
June 23, 2020 at 4:05 PM

How then to check the notifictions that come through ?

Reply
avatar
Anonymous
June 28, 2020 at 12:51 PM

but not able to remove geo location push notification from naukri.com?
any help is welcome.

Reply
avatar
July 7, 2021 at 4:59 PM

Not able to block notification any luck?

Reply
avatar