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.
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.
i want to click on allow for the location popup ..how should i do that? please help
ReplyThank you Anuku jain, Your blog is help many Automation engineers Once again Thank you so much.
ReplyHow then to check the notifictions that come through ?
Replybut not able to remove geo location push notification from naukri.com?
Replyany help is welcome.
Not able to block notification any luck?
Reply