Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use fake-web cam on mozilla firefox using selenium java

I am trying to automate a website that has a webcam stream in it. In order to automate it, I need some way to fake a webcam.

I know the option -use-fake-device-for-media-stream simulates a webcam in Chrome. This is working for me in Chrome. Now I need to get the same working in Firefox.

I got the following information from internet while researching on this. "In Firefox, a special fake:true variable in the getUserMedia() calls will achieve this".

I did not understand how to code this up. Can anyone advice please? I am using java based selenium.

like image 284
Juby Avatar asked Mar 11 '23 18:03

Juby


2 Answers

This can be done in Firefox at various levels:

  • System
  • User Level
  • Profile Level etc

Set following props in either user.js, pref.js or channel-prefs.js

pref("media.navigator.permission.disabled", true);
pref("media.navigator.streams.fake", true);

OR

user_pref("media.navigator.permission.disabled", true);
user_pref("media.navigator.streams.fake", true);

Then reboot your machine or restart firefox service.

After that call your URL which invokes getUserMedia() Firefox will display Fake Audio/Video.

like image 185
user5958722 Avatar answered Apr 06 '23 14:04

user5958722


You can use:

profile.setPreference('media.navigator.streams.fake', true);
like image 39
Ostap Maliuvanchuk Avatar answered Apr 06 '23 15:04

Ostap Maliuvanchuk