ChromeDriver Remote - disable notifications using browserstack

Viewed 4966

I use selenium on BrowserStack service and I need to disable chrome notifications [ex. on screenshot]. Locally I do it with the following code, but all manuals in Internet didn't help me to get it working on remote ChromeDriver on BrowserStack.

ChromeDriver notification.jpg

>@Before
    public void SetUP() throws Exception {
        ChromeOptions options = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<String, Object>();
        prefs.put("profile.default_content_setting_values.notifications", 2);
        options.setExperimentalOption("prefs", prefs);
        options.addArguments("--start-maximized");
        options.addArguments("disable-popup-blocking");
        DesiredCapabilities caps = DesiredCapabilities.chrome();
        caps.setCapability("browser", "Chrome");
        caps.setCapability("browser_version", "49.0");
        caps.setCapability("os", "Windows");
        caps.setCapability("os_version", "10");
        caps.setCapability("resolution", "1280x1024");
        caps.setCapability(ChromeOptions.CAPABILITY, options);
        caps.setCapability("browserstack.debug", "true");
        driver = new RemoteWebDriver(new URL(URL), caps);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

2 Answers
Related