- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to handle chrome notification in Selenium?
We can handle Chrome notification in Selenium webdriver. These are generally known as the web push notifications and can be handled with the help of the ChromeOptions class. The below image shows a notification from the browser Chrome −
We have to create an object of this ChromeOptions class and apply the addArguments method on it. The parameter --disable-notifications is passed as a parameter to this method. Finally, this information is sent to the ChromeDriver.
Syntax
ChromeOptions o = new ChromeOptions(); o.addArguments("--disable-notifications");
Example
import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.WebDriver; public class NotificationChrome { public static void main(String[] args) throws IOException { //object of ChromeOptions ChromeOptions o = new ChromeOptions(); //set browser options o.addArguments("--disable-notifications"); System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); // pass browser option to webdriver WebDriver driver = new ChromeDriver(o); //implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //URL launch driver.get("https://www.justdial.com/Bangalore/Bakeries"); } }
Output
- Related Articles
- How does Selenium Webdriver handle SSL certificate in Chrome?
- How to handle frames in Selenium?
- How to Handle alerts in Selenium?
- How to handle popup windows in Selenium?
- How to launch Chrome Browser via Selenium?
- How to handle proxy in Selenium in Java?
- How to run Selenium WebDriver test cases in Chrome?
- How to use a specific chrome profile in selenium?
- How to handle web based alerts in Selenium?
- How to handle frames in Selenium with python?
- How to open chrome default profile with selenium?
- How to handle frames in Selenium Webdriver in Python?
- How to invoke the Chrome browser in Selenium with python?
- How to mute all sounds in chrome webdriver with selenium?
- How to set default download directory in selenium Chrome Capabilities?

Advertisements