Handle Browser Notification using Selenium

First lets discuss what is browser notification?

Lot of websites have started sending notifications these days. You get these notification on desktop or device even when the concerned web page is not open in your browser. These are also called as Web push notifications. These notifications looks like below in firefox and chrome browser:

BrowserNotification

Browser Notification In Firefox

You can see this notification by visiting to jabong.com website.

BrowserNotificationChrome

Browser Notification In Chrome

You can see this notification by visiting to https://drupal-stage-web.weather.com website.

If we need to handle browser notification using Selenium in Firefox browser, we should use following code:

While using this code, make sure gecko driver path is correctly configured. In case, you are not aware of Firefox Profile Class. Please visit below Selenium java doc to know more about its methods and usage.

http://seleniumhq.github.io/selenium/docs/api/java/index.html

If we need to handle browser notification using Selenium in Chrome browser, we should use following code:

While using this code, make sure chrome driver path is correctly configured. In case, you are not aware of Chrome Options Class. Please visit below Selenium java doc link provided above.

Do let us know if any issue is faced while handling browser/ web push notifications using selenium.

One Comment

  1. March 6, 2018 at 6:29 am

    Thanks for this. Fixed firefox notifications issue by this fix..

Leave a Reply

bodrum escort - eskişehir esc - mersin escort - mersin escort bayan - mersin esc