Skip to main content

Upload video files and simulate the camera

Important: This feature is currently a Private Beta service and available only under Desktop and Mobile Pro, and Enterprise Pro plans. For more details, check out our pricing page.

BrowserStack Automate enables you to upload video files to BrowserStack devices to verify various use cases, such as testing web apps and websites that require access to camera and video output, scanning QR code to your web app, testing the video recording feature, etc.

In this guide, you will learn:

Supported OS and browsers

Supported Platform Supported Versions Supported Browsers
Android 9 and above Chrome 101 and above
iOS 12 and above Safari 10 and above
Windows 7 and above Chrome 101 and above
Edge 101 and above
macOS Any Chrome 101 and above
Edge 101 and above
Note:
  • Camera Video Injection feature is currently not supported on Oppo, Vivo, Huawei, Sony, and Samsung Galaxy M32 devices.
  • You can upload video files in the .mp4 format only, with maximum file size of 50 MB.

Upload your video files

Prior to starting the test execution, upload the video files using media REST APIs.

curl -u "username:accesskey" -X POST "https://api-cloud.browserstack.com/automate/upload-media" -F "file=@/path/to/app/file/test.mp4"

The REST API returns a response media_url for each successful file upload.

{
    "media_url" : "media://<hashedid>"
}
Note: This feature is currently a Private Beta service and available only under Desktop and Mobile Pro, and Enterprise Pro plans. For more details, check out our pricing page.

Inject the video file using the Automate capability

Use the capability values cameraInjection for W3C protocol and browserstack.cameraInjection for JSON wire protocol in your test scripts.

Capability Description
cameraInjection Set this capability to "true" if you want to use your video files to emulate camera in the test.
cameraInjectionUrl Add this capability with media_url of the video files to emulate camera in the test.
Capability Description
browserstack.cameraInjection Set this capability to "true" if you want to use your video files to emulate camera in the test.
browserstack.cameraInjectionUrl Add this capability with media_url of the video files to emulate camera in the test.
Note: After injecting the video using the correct capability, program your test script to click the record button to start recording the video.

Example:

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("cameraInjection", "true");
browserstackOptions.put("cameraInjectionUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
capabilities.setCapability("bstack:options", browserstackOptions);
var capabilities = {
	'bstack:options' : { 
			"cameraInjection" : "true"
			"cameraInjectionUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e"
		}
}
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("cameraInjection", "true");
browserstackOptions.Add("cameraInjectionUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
capabilities.AddAdditionalOption("bstack:options", browserstackOptions);
desired_cap = {
	'bstack:options' : {
		"cameraInjection" : "true",
		"cameraInjectionUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e",
	},
}
capabilities = {
	'bstack:options' => {
		"cameraInjection" => "true",
		"cameraInjectionUrl" => "media://575927ad18ae787c065e680dc3ee864725cd809e",
	},
}
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.cameraInjection","true");
desiredCapabilities.setCapability("browserstack.cameraInjectionUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
var capabilities = {
	"browserstack.cameraInjection" : "true"
	"browserstack.cameraInjectionUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e"
}
ChromeOptions capability = new ChromeOptions();
capability.AddAdditionalCapability("browserstack.cameraInjection", "true");
capability.AddAdditionalCapability("browserstack.cameraInjectionUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
desired_cap = {
	"browserstack.cameraInjection" = "true",
	"browserstack.cameraInjectionUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e",
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.cameraInjection"] = "true"
caps["browserstack.cameraInjectionUrl"] = "media://575927ad18ae787c065e680dc3ee864725cd809e"

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Download Copy