我已经尝试过下面的代码,但它不起作用
ChromeOptions option = new ChromeOptions();
option.addArguments("--disable-notifications");
option.addArguments("--disable-popup-blocking");
driver = new ChromeDriver(option);
我希望您不要太关心会话、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);