Java 如何使用selenium在Chrome版本90.0.4430.93上允许摄像头访问
我想允许对网站进行拍照许可“https://webcamtests.com/" 我尝试使用:Java 如何使用selenium在Chrome版本90.0.4430.93上允许摄像头访问,java,selenium-webdriver,Java,Selenium Webdriver,我想允许对网站进行拍照许可“https://webcamtests.com/" 我尝试使用:options.addArguments(“对媒体流使用假ui”) 或 ChromeOptions选项=新的ChromeOptions(); HashMap contentSetting=新建HashMap(); HashMap profile=新的HashMap(); HashMap prefs=新的HashMap(); contentSetting.put(“媒体流”,1); profile.put(
options.addArguments(“对媒体流使用假ui”)代码>
或
ChromeOptions选项=新的ChromeOptions();
HashMap contentSetting=新建HashMap();
HashMap profile=新的HashMap();
HashMap prefs=新的HashMap();
contentSetting.put(“媒体流”,1);
profile.put(“托管\u默认\u内容\u设置”,contentSetting);
优先放置(“配置文件”,配置文件);
选项。设置实验选项(“prefs”,prefs);
WebDriverManager.chromedriver().setup();
驱动程序=新的色度驱动程序(可选);
driver.manage().window().maximize();
驱动程序。获取(“https://webcamtests.com/");
但它不起作用,我不知道为什么会产生任何可以包含在您的问题中的错误?没有错误,但我不能允许相机许可,我不知道为什么
ChromeOptions options = new ChromeOptions();
HashMap<String, Integer> contentSetting = new HashMap<String, Integer>();
HashMap<String, Object> profile = new HashMap<String, Object>();
HashMap<String, Object> prefs = new HashMap<String, Object>();
contentSetting.put("media_stream",1);
profile.put("managed_default_content_settings",contentSetting);
prefs.put("profile",profile);
options.setExperimentalOption("prefs",prefs);
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("https://webcamtests.com/");