如何在 selenium java 中自动化时禁用 chrome 通知弹出窗口?

问题描述 投票:0回答:1

如何禁用 chrome 通知弹出窗口

我已经尝试过下面的代码,但它不起作用

            ChromeOptions option = new ChromeOptions();
            option.addArguments("--disable-notifications");
    option.addArguments("--disable-popup-blocking");
    driver = new ChromeDriver(option);

    
java selenium-webdriver selenium-chromedriver selenium-java
1个回答
0
投票

我希望您不要太关心会话、cookies 或缓存数据。如果没有,则可以在隐身模式下禁用该特定通知。因此,您可以按如下方式更改代码

ChromeOptions option = new ChromeOptions();
option.addArguments("--incognito");//This would open the Chrome in incognito mode and it would block most of the popups
driver = new ChromeDriver(option);
© www.soinside.com 2019 - 2024. All rights reserved.