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

試著忘記壹切 提交于 2020-08-24 10:23:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!