如何使用带有Java的Selenium WebDriver在Firefox中允许或拒绝通知麦克风和摄像头弹出窗口 [英] How to allow or deny notification of microphone and camera popup in Firefox using Selenium WebDriver with Java

查看:504
本文介绍了如何使用带有Java的Selenium WebDriver在Firefox中允许或拒绝通知麦克风和摄像头弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Java的Selenium WebDriver的情况下,我无法在Firefox浏览器中单击访问摄像机身份验证弹出窗口的 Allow (允许)按钮.

I am not able to click on the Allow button of access camera authentication popup in Firefox browser using Selenium WebDriver with Java.

下面是正在使用的代码:

Below is the code which is using:

Map<String, Object> prefs = new HashMap<String, Object>();
WebDriverManager.firefoxdriver().setup();
prefs.put("profile.default_content_setting_values.media_stream_mic", 1);
prefs.put("profile.default_content_setting_values.media_stream_camera", 1);
prefs.put("profile.default_content_setting_values.notifications", 1);        
prefs.put("credentials_enable_service", false); 
prefs.put("profile.password_manager_enabled", false);


FirefoxOptions options = new FirefoxOptions();
options.addPreference("dom.webnotifications.enabled", false);
options.addArguments("--disable-infobars");
options.addArguments("use-fake-ui-for-media-stream");
options.addArguments("start-maximized");
options.addArguments("--disable-extensions");
driver = new FirefoxDriver(options);

这是弹出窗口的外观:

推荐答案

您可以使用以下首选项(在这种情况下允许):

You can use the following preferences (in this case to allow):

...
options.addPreference("permissions.default.microphone", 1);
options.addPreference("permissions.default.camera", 1);
...

希望它对您有帮助!

这篇关于如何使用带有Java的Selenium WebDriver在Firefox中允许或拒绝通知麦克风和摄像头弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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