6

I am writing a test automation framework using Java and Selenium. I am running the tests both locally and also using Browserstack.

The website under tests includes features that use the PC's camera to scan documents and faces.

Instead of using the PC's webcam I want to fake a stream.

Has anybody managed to do this?

I am using the following Chrome options:

chromeOptions.addArguments("--use-fake-ui-for-media-stream");
chromeOptions.addArguments("--use-fake-device-for-media-stream");
chromeOptions.addArguments("--use-file-for-fake-video-capture=C:/deleteme/bus.y4m");

When I click on the button that would normally open the webcam, the webcam does NOT open, so it looks like it is doing something. However my video doesn't play.

Has anybody got these to work for a scenario similar to mine and could provide more info on how to do it?

Any help would be appreciated. Thanks.

Matt
  • 773
  • 2
  • 15
  • 30

1 Answers1

1

I solved that converting a mp4 file to mjpeg, which is a format that also can be used, and setting my chromedriver same as you did, but using a relative path to the file.

options.addArguments("--use-fake-ui-for-media-stream",
                     "--use-fake-device-for-media-stream",
                     "--use-file-for-fake-video-capture=src/test/resources/sample_640x360.mjpeg"); 

This thread helped me to get there: https://stackoverflow.com/a/52188760/1843429

Lano
  • 593
  • 1
  • 7
  • 13