Disable Chrome notifications (Selenium)

后端 未结 5 1509
暗喜
暗喜 2020-12-06 17:46

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

Notifications like this one:

The

5条回答
  •  太阳男子
    2020-12-06 18:49

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

    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);
    

提交回复
热议问题