When generating mobile automation scripts (Appium/Selenium) that require Camera / Image Injection on BrowserStack App Automate, follow these guidelines:
-
Required Capabilities:
- Always enable camera injection: set capability
browserstack.enableCameraImageInjection(orenableCameraImageInjection) totrue. - Pass the media URL using the capability
browserstack.cameraInjectionMedia(orcameraInjectionMedia).
- Always enable camera injection: set capability
-
Default Media for QR Code Testing:
- For all QR code scanning requirements, use the existing pre-uploaded media ID:
media://a85ff3f4d9c46cff13a7e88eef2308fa5a118da4
- For all QR code scanning requirements, use the existing pre-uploaded media ID:
-
Uploading Custom Images (If Required):
- If a custom image is needed, use the BrowserStack REST API to upload media prior to test execution:
curl -u "<BROWSERSTACK_USERNAME>:<BROWSERSTACK_ACCESS_KEY>" \ -X POST "[https://api-cloud.browserstack.com/app-automate/upload-media](https://api-cloud.browserstack.com/app-automate/upload-media)" \ -F "file=@/path/to/image.png" \ -F "custom_id=<CustomID>"
- Supported formats: JPG, JPEG, PNG (max file size: 10 MB).
- Use the returned
media_url(e.g.,media://...) in thecameraInjectionMediacapability.
- If a custom image is needed, use the BrowserStack REST API to upload media prior to test execution: