ChromeDriver Access To Mic/Camera For Selenium Test

Viewed 194

I’m trying to run an end to end test for a video chat platform, using the 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.

let options = new Options();

options.set("preferences.profile.content_settings.exceptions.media_stream_camera.'<localhost-address>,*'.setting", 1)
options.set("preferences.profile.content_settings.media_stream_mic.'<localhost-address>,*'.setting", 1);

let driver = await new Builder().setChromeOptions(options).forBrowser("chrome").build();
let options = new Options();

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

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

The pop-up still comes up and I can’t find a way to interact with it. Using a fake device/UI doesn’t resolve the issue, because it’s incompatible (to my knowledge) with Twilio, which the platform also uses.

Does anyone know how to default the ChromeDriver to allow camera/mic access during testing?

Update: The following code runs so that the pop up doesn't appear. But when the driver gets to the point that pop up would show up, the browser instance quits and the test ends. Is it impossible to stream from a webcam via Selenium?

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();
0 Answers
Related