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

469 views Asked by At

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

1

There are 1 answers

2
Dylan Lacey On

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.