Skip to main content
🚀 Self Healing AI Agent now live in App Automate! Auto-fix flaky tests instantly with zero code changes. Enable now!
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

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

The Camera preview feature is supported only on 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("enableCameraVideoInjection", "true");
browserstackOptions.put("videoUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
capabilities.setCapability("bstack:options", browserstackOptions);
var capabilities = {
	'bstack:options' : { 
			"enableCameraVideoInjection" : "true"
			"videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e"
		}
}
desired_cap = {
	'bstack:options' : {
		"enableCameraVideoInjection" : "true",
		"videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e",
	},
}
capabilities = {
	'bstack:options' => {
		"enableCameraVideoInjection" => "true",
		"videoUrl" => "media://575927ad18ae787c065e680dc3ee864725cd809e",
	},
}
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("enableCameraVideoInjection", "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.enableCameraVideoInjection","true");
desiredCapabilities.setCapability("browserstack.videoUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");
var capabilities = {
	"browserstack.enableCameraVideoInjection" : "true"
	"browserstack.videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e"
}
desired_cap = {
	"browserstack.enableCameraVideoInjection" = "true",
	"browserstack.videoUrl" : "media://575927ad18ae787c065e680dc3ee864725cd809e",
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.enableCameraVideoInjection"] = "true"
caps["browserstack.videoUrl"] = "media://575927ad18ae787c065e680dc3ee864725cd809e"
ChromeOptions capability = new ChromeOptions();
capability.AddAdditionalCapability("browserstack.enableCameraVideoInjection", "true");
capability.AddAdditionalCapability("browserstack.videoUrl", "media://575927ad18ae787c065e680dc3ee864725cd809e");

Enable camera preview

BrowserStack’s injection features let you test camera-based workflows by replacing the live camera feed with a pre-selected image or video file.

Enabling the camera preview ensures that your injected media is correctly rendered on these layers, allowing your tests to interact with the UI and capture media successfully.

To test your app’s camera preview functionality, set the enableCameraPreview capability to true. This displays a live preview of the image or video being injected, allowing you to verify UI elements around the camera view.

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

Capability Description Expected values
enableCameraPreview Enable camera preview 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 Camera preview:

Capability Description Expected values
enableCameraPreview Enable camera preview true/false
DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("enableCameraPreview", "true");
var capabilities = {
  	'bstack:options' : {
  		"enableCameraPreview" : "true",
  	},
}
desired_cap = {
  	'bstack:options' : {
  		"enableCameraPreview" : "true",
  	},
}
capabilities = {
    'bstack:options' => {
        "enableCameraPreview" => "true",
    },
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("enableCameraPreview", "true");
Capability Description Expected values
browserstack.enableCameraPreview Enable camera preview true/false
  • The Camera preview feature is available only with the Pro plan.
  • The Camera preview feature is supported only on Android 9 and above.
  • You must set enableCameraPreview along with the capabilities for either Camera image injection or Video injection.

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