Allow ChromeDriver Mic/Video Access

1,424 views
Skip to first unread message

Annetta

unread,
Mar 21, 2021, 11:15:07 AM3/21/21
to Selenium Users

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. 

Version 1:

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(browser).build();

Version 2:

let options = new Options();

options.setUserPreferences({"preferences.profile.content_settings.exceptions.media_stream_camera.'http://localhost:3005,*'.setting": 1,

 "preferences.profile.content_settings.media_stream_mic.'http://localhost:3005,*'.setting": 1});

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


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


Jeanne Almagor

unread,
Mar 22, 2021, 12:44:55 AM3/22/21
to Selenium Users
I'm having exactly the same problem...
I can not find any solution but i was thinking, may be it could help if i'll find the solution how to open the test in ne Chrome tab, with my user and not in new  blank window. If i open in new tab i can just disable the Chrome Pop Up, in new blank window i can not disable it... But i can not find solution to this either.
Let me know please if you have any ideas.

Annetta

unread,
Mar 22, 2021, 7:54:04 PM3/22/21
to Selenium Users
Thanks for the response, unfortunately I don't think you can get the ChromeDriver to automatically use your Chrome settings. I believe that's the point of setting ChromeOptions, just not sure why it's not working here. I'll keep looking into it though. Let me know if you make any headway!

David

unread,
Mar 22, 2021, 8:37:57 PM3/22/21
to Selenium Users
Have you checked with the ChromeDriver team or submitted a bug there? It might be worthwhile, this may be ChromeDriver specific after all.

Annetta

unread,
Mar 26, 2021, 1:52:22 PM3/26/21
to Selenium Users
I hadn't thought to reach out to ChromeDriver specifically, but I will! Thanks! I am also having issues with the webcam in SafariDriver, so I think its a WebDriver issue overall. But ChromeDriver seems like a good place to start for sure

David

unread,
Mar 26, 2021, 4:23:14 PM3/26/21
to Selenium Users
Good to know, was there any issue with WebCam on FirefoxDriver, not sure if applicable for InternetExplorerDriver, just checking to see how many "drivers" are affected. Or those other browsers weren't tested?

Annetta

unread,
Mar 26, 2021, 6:34:14 PM3/26/21
to Selenium Users
Haven't tested the other browsers yet, but it's looking like it could be a Mac issue. Going to run some tests on pc to see, still waiting on a response in the ChromeDriver group too. 

Jeanne Almagor

unread,
Apr 4, 2021, 4:39:56 PM4/4/21
to Selenium Users

Hello,
This code worked for me in Chrome, it opens tab with "fake" mode, which doesn't allow to see the list of the Audio/Speaker devices which are available on the machine, but still does the other work. I was told that it's good enough and i can always to test the visibility of the devices lists manually.
This is the code in Chrome:
ChromeOptions options = new ChromeOptions();
    options.addArguments("use-fake-device-for-media-stream");
    options.addArguments("use-fake-ui-for-media-stream");
                            WebDriver driver = new ChromeDriver(options);

Now i'm trying to do the same in Edge and it doesn't work. Eclipse says that options.addArguments in Edge not supported, i've tried to upgrade latest Eclipse, still no luck...

David

unread,
Apr 5, 2021, 5:04:55 PM4/5/21
to Selenium Users
On the Edge issue, it could be that the options are specific to the WebDriver implementation of the browser. While Edge (and Opera, and other browsers) are based off Chrome/Chromium, it doesn't mean that the command line startup arguments of the browser & WebDriver implementation is an exact clone as well. Might have to check with the Edge community/developers to confirm.

SuperKevy

unread,
Apr 5, 2021, 5:09:40 PM4/5/21
to Selenium Users
I don't know if anyone hit this thread:  How to enable 'Mircophone' access in Edge browser using Selenium? - Microsoft Tech Community
The last note gives a hint about a Selenium 4+ or a plugin need for Sele v3. 

Reply all
Reply to author
Forward
0 new messages