'How to handle browser notifications for safari browser while executing tests on Saucelabs via Selenium?

I am trying to execute some scripts from our in-house existing framework on the safari browser on Saucelabs. As soon as the application is logged in I get the browser notification to Allow or Don't Allow but I am not able to interact with it.

enter image description here

I tried using all possible suggestions available, but nothing works.

        SafariOptions browserOptions = new SafariOptions();
        browserOptions.setCapability("platformName", "macOS 10.15");
        browserOptions.setCapability("browserVersion", "latest");
        Map<String, Object> sauceOptions = new HashMap<>();
        Map<String, Object> pref = new HashMap<>();
        pref.put("permissions.default.desktop-notification",0);
        sauceOptions.put("screenResolution", "1024x768");
        sauceOptions.put("customData",pref);
        browserOptions.setCapability("sauce:options", sauceOptions);
        browserOptions.setCapability("--disable-notifications", true);

How Do I take care of this? Did I miss anything in configurations? Please help. Thanks in advance



Solution 1:[1]

There is currently (Feb 2022) no way of blocking notification pop-ups for websites on Mobile Safari.

If this is your own site, I'd suggest disabling that feature during tests.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Dylan Lacey