问题
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.
回答1:
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.
回答2:
You can use:
profile.setPreference('media.navigator.streams.fake', true);
来源:https://stackoverflow.com/questions/38234576/how-to-use-fake-web-cam-on-mozilla-firefox-using-selenium-java