[FIXED] Disable Chrome notifications (Selenium)


I just want to disable Chrome notifications in the Chrome opened by a Selenium Java application. (using java code)

Notifications like this one:

enter image description here

The problem is that settings manually set are lost after browser’s window is closed.


This question was answered in the: “chromedriver-users” google forum.
This is the working answer:

Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.notifications", 2);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);

Answered By – fabio_vac

Answer Checked By – Dawn Plyler (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published