对于不同的浏览器/驱动程序,需要设置不同的配置文件/选项:
火狐
FirefoxProfile ffprofile = 新的 FirefoxProfile();
ffprofile.setPreference("dom.webnotifications.enabled", false);
WebDriver 驱动程序 = 新的 FirefoxDriver(ffprofile);
Chrome(来源:https : //stackoverflow.com/a/34368704/904375)
映射偏好 = new HashMap();
prefs.put("profile.default_content_setting_values.notifications", 2);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);
| 归档时间: |
|
| 查看次数: |
10979 次 |
| 最近记录: |