Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disabling notification using selenium for firefox browser

enter image description here

I want to complete disable the notification when i launch a firefox browser

like image 425
Anwesh Hosamane JP Avatar asked Dec 24 '22 18:12

Anwesh Hosamane JP


1 Answers

For different browsers/drivers there are different profiles/options that need to be set:

Firefox

FirefoxProfile ffprofile = new FirefoxProfile();
ffprofile.setPreference("dom.webnotifications.enabled", false);
WebDriver driver = new FirefoxDriver(ffprofile);

Chrome (Source: https://stackoverflow.com/a/34368704/904375)

Map prefs = new HashMap();
prefs.put("profile.default_content_setting_values.notifications", 2);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);
like image 55
Zeeshan Siddiqui Avatar answered Jun 21 '23 11:06

Zeeshan Siddiqui