How to handle browser level notification using Selenium Webdriver

前端 未结 6 2182
Happy的楠姐
Happy的楠姐 2020-12-17 22:03

I am Automating some test cases using Selenium Webdriver and core Java,in chrome browser for one test case on clicking button I am getting browser level notification \'Show

6条回答
  •  伪装坚强ぢ
    2020-12-17 22:24

    You can use below code to allow chrome to send notifications:

    ChromeOptions options=new ChromeOptions();
    Map prefs=new HashMap();
    prefs.put("profile.default_content_setting_values.notifications", 1);
    //1-Allow, 2-Block, 0-default
    options.setExperimentalOption("prefs",prefs);
    ChromeDriver driver=new ChromeDriver(options);
    

    It works perfectly for me. Let me know if it doesn't work for you. Cheers!!

提交回复
热议问题