id | title | sidebar_label | description | keywords | url | site_name | slug | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
camera-image-injection |
Camera Image Injection |
Camera Image Injection |
Now you can test image capturing and QR code or Barcode scanning in your app on LambdaTest Real Device Cloud Platform with 3000+ real mobile devices. |
|
LambdaTest |
camera-image-injection/ |
import CodeBlock from '@theme/CodeBlock'; import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.lambdatest.com" },{ "@type": "ListItem", "position": 2, "name": "Support", "item": "https://www.lambdatest.com/support/docs/" },{ "@type": "ListItem", "position": 3, "name": "Camera Image Injection", "item": "https://www.lambdatest.com/support/docs/camera-image-injection/" }] }) }} ></script>Camera Image Injection feature allows you to test image capturing, QR code scanning, and barcode scanning functionalities in your app across 3000+ real devices on the LambdaTest Real Device Cloud platform.
This tool is ideal for testing features such as:
- Scanning QR codes linked to embedded URLs
- Check scanning
- Capturing profile photos
- Uploading images to your app
LambdaTest utilizes Sensor Instrumentation to integrate with various mobile sensors, including the camera. When you enable Image Injection for a session, LambdaTest injects its camera code module into your app through Sensor Instrumentation. This module then mocks or overrides the Android or iOS SDK used in your app.
- Compatible with 3000+ real mobile devices
- Supports image capturing, QR code scanning, and barcode scanning
- Seamless integration with your existing app testing workflow
:::warning note
- Video capture and other media types are not currently supported.
- For iOS apps signed with Enterprise Certificates, app resigning (a prerequisite for using the Image Injection tool) is not available. :::
Below given is the list of Camera APIs which are supported by LambdaTest Image Injection tool. Please ensure that your app uses these APIs only to enable Image Injection.
📕 For details, please check [Apple documentation](https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate/1619126-imagepickercontroller)| | `AVCapturePhoto` iOS SDK class for receiving captured photos from `AVCapturePhotoOutput` API.
📕 For details, please check [Apple Documentation](https://developer.apple.com/documentation/avfoundation/avcapturephoto).| | `AVMetadataMachineReadableCodeObject` is a subclass of `AVMetadataObject` iOS SDK class for scanning QR/Barcodes.
📕 For more details, please check [AVMetadataMachineReadableCodeObject Documentation](https://developer.apple.com/documentation/avfoundation/avmetadatamachinereadablecodeobject) |
📕 For details, please check [CameraX documentation](https://developer.android.com/training/camerax) | | `Camera` API is used.
📕 For details, please check [Camera documentation](https://developer.android.com/training/camera-deprecated)| | `Camera2` API is used.
📕 For details, please check [Camera2 documentation](https://developer.android.com/training/camera2)| | `ACTION_IMAGE_CAPTURE` is standard Intent action that can be sent to have the camera application capture an image and return it.
📕 For details, please check [MediaStore documentation](https://developer.android.com/reference/android/provider/MediaStore)|
This section explains how to use Image Injection with App automation. This section will also teach you how to use image injection for all the possible test cases for your app along with other useful information.
You can use the following curl command to upload any image of your choice to the LambdaTest cloud. Please note that we support only JPG, JPEG, and PNG formats which can be 10 MB or less.
Response of above cURL will be a JSON object containing the media_url
of the format - lt://MEDIA123456789123456789 as shown below.
{
"media_url":"lt://MEDIA123456789123456789",
"name":"IMG_123.jpg",
"status":"success",
"custom_id":"SampleImage"
}
You can use the appium capability to turn the image injection on in your application. Just add "enableImageInjection": True
in the desired capabilities while writing the automation script. By adding this capability the app undergoes Sensor Instrumentation, which was described earlier in the documentation. Also adding media url "media": "lt://MEDIA123456789123456789"
in the capabilities to inject the image is now optional and can be passed in LambdaHook as mentioned in step 3.
Refer to the code snippets given below to upload the image with the action ImageInjection
. Please make sure that the image needs to be injected before the camera is triggered in your application. This is due to the fact that the camera only captures the image injected at the last.
:::info
Use Case: This feature can be used when you want to test injecting more than one images in single test at different instances. The image injected through above process will replace the image which you put in previous steps.
:::
You need to first add a logic to inject the uploaded image in the script. Thereafter add the logic to click the camera button in the mobile app. This will show you the last injected image on your mobile app screen.
📕 Check the documentation for Camera Image Injection feature in Manual App Testing on Real devices