Skip to main content
No Result Found

Test video injection

Inject video files to test video-based scenarios with App Automate capability.

This feature is available only under Device Cloud Pro plan. For more details, check out our pricing page.

App Automate’s video injection feature lets you upload video files to BrowserStack devices to test video-based features. Video injection simulates the camera video function and uses the uploaded video as an input to mimic the camera video function.

Supported OS versions

BrowserStack supports video injection in the following OS versions:

OS OS version
iOS iOS 13 and above
Android Android 9 and above

Upload video

Upload your desired video to BrowserStack using the following cURL command.

Request
Copy icon Copy

BrowserStack only accepts files under 15 MB in the .mp4 format.

Here is a sample response that includes the media ID to be set in the videoUrl used later in the test script.

Response
Copy icon Copy

Enable video injection

To use this feature in your Appium session, set the enableCameraVideoInjection capability at the start of your test session.

If you are using BrowserStack SDK, you can set the following capability within the browserstack.yml file:

Capability Description Expected values
enableCameraVideoInjection Enable video injection true/false
browserstack.yml
Copy icon Copy

BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.

Use the following code snippet to enable Video injection:

Capability Description Expected values
enableCameraVideoInjection Enable video injection true/false
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("cameraVideoInjection", "true");
browserstackOptions.put("videoUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
capabilities.setCapability("bstack:options", browserstackOptions);
var capabilities = {
	'bstack:options' : { 
			"cameraVideoInjection" : "true"
			"videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e"
		}
}
desired_cap = {
	'bstack:options' : {
		"cameraVideoInjection" : "true",
		"videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e",
	},
}
capabilities = {
	'bstack:options' => {
		"cameraVideoInjection" => "true",
		"videoUrl" => "media://575927ad18ae787c065e680dc3ee864725cd809e",
	},
}
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("cameraVideoInjection", "true");
browserstackOptions.Add("videoUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
capabilities.AddAdditionalOption("bstack:options", browserstackOptions);
Capability Description Value
browserstack.enableCameraImageInjection Enable camera injection true/false
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.cameraVideoInjection","true");
desiredCapabilities.setCapability("browserstack.videoUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
var capabilities = {
	"browserstack.cameraVideoInjection" : "true"
	"browserstack.videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e"
}
desired_cap = {
	"browserstack.cameraVideoInjection" = "true",
	"browserstack.videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e",
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.cameraVideoInjection"] = "true"
caps["browserstack.videoUrl"] = "media://575927ad18ae787c065e680dc3ee864725cd809e"
ChromeOptions capability = new ChromeOptions();
capability.AddAdditionalCapability("browserstack.cameraVideoInjection", "true");
capability.AddAdditionalCapability("browserstack.videoUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");

Inject the uploaded video

Inject the uploaded video using BrowserStack’s custom executor with the action cameraVideoInjection as shown in the following code snippets. Ensure the video is injected before the camera is triggered in the app as the camera only captures the last injected video.

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor: {\"action\":\"cameraVideoInjection\", \"arguments\": {\"videoUrl\" : \"media://<id>\"}}")
await driver.execute("browserstack_executor: {\"action\":\"cameraVideoInjection\", \"arguments\": {
  \"videoUrl\" : \"media://<id>\"
}}”)
driver.execute_script("browserstack_executor: {\"action\":\"cameraVideoInjection\", \"arguments\": {
    \"videoUrl\" : \"media://<id>\"
}}”)
@driver.execute_script("browserstack_executor: {\"action\":\"cameraVideoInjection\", \"arguments\": {
    \"videoUrl\" : \"media://<id>\"
}}”)
((IJavaScriptExecutor)driver).ExecuteScript("browserstack_executor: {\"action\":\"cameraVideoInjection\", \"arguments\": { \"videoUrl\" : \"media://<id>\"}}");

Trigger camera in the app & take a video

Add the logic to click the camera button in the mobile app after the logic to inject the uploaded video is added in the script. The video captured from the camera is the last injected video.

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 Check Circle