I've automated a web app that opens up the camera and takes a photo. On my local machine the Selenium script executes and captures the photo (running in headless mode). However, when I run the script via Jenkins server, no photo is being captured. The automation script is written in Java 11. I'm using Firefox as the browser. My Selenium is version: '4.1.2'. Before launching the browser I've granted access to the camera via a profile as below:
// set the profile to allow camera access
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("media.navigator.permission.disabled", true);
firefoxOptions.setProfile(profile);
System.setProperty(systemProperty, driverPath);
webDriver = new FirefoxDriver(firefoxOptions);
Logic is telling me this is because the Jenkins server does not have a camera. If that is the case, is there a way to fake a camera? Thanks for any pointers.camera on jenkins server
Opening the camera and taking the photo are straightforward, snippet:
@Step ("capture photo")
public ConfirmPhotoPO capturePhoto(){
SeleniumWaitUtil.waitUntilElementToBeClickable(captureBtn);
// try capture a photo, and check if we can upload
clickElement(captureBtn);
return new ConfirmPhotoPO();
}
The application is an Angular web app. With the above, the expectation is that the camera page is opened and the button clicked and the photo captured. However, only the camera page is opened (which has the capture photo button), but no photo is being captured.

The problem may be the camera having nothing to capture. Give some mock camera inputs that can be captured at this line -
Also make sure that the virtual environment can handle camera input emulation.