'How to handle browser notification in selenium

I used the solution of Stack over flow for controlling the browser notification while designing framework for Facebook. But I am still not able to handle it, code for it is given below :

public class Base {
    public ChromeDriver driver;
    public Properties pr = new Properties();
     @BeforeMethod
    public void method() throws FileNotFoundException{
         
        System.setProperty("webdriver.chrome.driver","E:\\selenium\\chromedriver.exe");
        Map<String, Object> prefs = new HashMap<String, Object>();

        //add key and value to map as follow to switch off browser notification
        //Pass the argument 1 to allow and 2 to block
        prefs.put("profile.default_content_setting_values.notifications", 1);

        //Create an instance of ChromeOptions 
        ChromeOptions options = new ChromeOptions();

        
        options.setExperimentalOption("prefs", prefs);

        driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.get("https://www.facebook.com/login/");
        File s= new File("../Flipkart automation/Objectrepo.properties");
        FileReader fr = new FileReader(s);
            pr= new Properties();
            try {
                pr.load(fr);
            } catch (IOException e) {
                e.printStackTrace();
            }
        


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source