如何在Firefox浏览器中使用Selenium禁用通知 [英] how to disabling notification using selenium for firefox browser

查看:235
本文介绍了如何在Firefox浏览器中使用Selenium禁用通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在启动Firefox浏览器时完全禁用通知

I want to complete disable the notification when i launch a firefox browser

推荐答案

对于不同的浏览器/驱动程序,需要设置不同的配置文件/选项:

For different browsers/drivers there are different profiles/options that need to be set:

Firefox


FirefoxProfile ffprofile = new FirefoxProfile();
ffprofile.setPreference("dom.webnotifications.enabled", false);
WebDriver driver = new FirefoxDriver(ffprofile);

Chrome (来源: https://stackoverflow.com/a/34368704/904375)


Map prefs = new HashMap();
prefs.put("profile.default_content_setting_values.notifications", 2);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);

这篇关于如何在Firefox浏览器中使用Selenium禁用通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆