Access Webcam/Mic

102 views
Skip to first unread message

Annetta

unread,
Mar 26, 2021, 2:46:51 PM3/26/21
to ChromeDriver Users

I’m trying to run an end to end test for a video chat platform, using ChromeDriver. I need to use the actual webcam stream on my computer to run the test. I’ve tried both versions of the following code, but neither actually defaults the mic/camera settings to allow. 

Version 1:

let options = new Options();

options.setUserPreferences({"preferences.profile.content_settings.exceptions.media_stream_camera.'<local-host-address>,*'.setting": 1, "preferences.profile.content_settings.media_stream_mic.'<local-host-address>,*'.setting": 1});

let driver = await new Builder().setChromeOptions(options).forBrowser(browser).build();

Version 2:

let options = new Options();

options.setUserPreferences({"profile.default_content_setting_values.media_stream_mic": 1, "profile.default_content_setting_values.media_stream_camera": 1});

let driver = await new Builder().setChromeOptions(options).forBrowser(browser).build();

In Version 1, the pop-up still comes up and I can’t find a way to click the allow button. In Version 2, the driver just quits when it gets the point where it would use the webcam/ mic. I tried setting the user data dir to the settings I have on my Chrome browser using the following code, but the pop up still comes up.

let options = new Options();

options.addArguments("user-data-dir=/Users/<username>/Library/Application Support/Google/Chrome/Default");

let driver = await new Builder().setChromeOptions(options).forBrowser(browser).build();

Using a fake device/UI doesn’t resolve the issue, we need to access the real webcam. Does anyone know how to do this?


Reply all
Reply to author
Forward
0 new messages