Skip to main content

Use Image Injection in AIQ Mobile Testing

The Set Camera

Use Image

functionInjection allowsin youAIQ toMobile setTesting an

Image injection lets a mobile test provide a controlled image to bethe usedapplication under test when triggeringthe scenario needs repeatable camera, upload, or visual-input behavior. Use controlled test images and avoid customer-sensitive content.

When to use image injection

  • Testing flows that ask the camera during a test. For example, you could use thisuser to injectupload a QR code into your test script.

    Compatibility Summary

    Service

    iOS

    Android

    Requirements

    Device

    Simulator

    Device

    Simulator

    On Premises

    Not supported

    Not supported

    Not supported

    Supported

    Update emulator settings.

    Sauce Labs

    Supported

    Not supported

    Supported

    Not supported

    Add capability: sauceLabsImageInjectionEnabled: true

    BrowserStack

    Supported

    Not supported

    Supported

    Not supported

    Add capability: enableCameraImageInjection: true

    LambdaTest

    Supported

    Not supported

    Supported

    Not supported

    Add capability: enableImageInjection: true

    On-Premises

    Available for Android emulators only when running AIQ locally.

    When running AIQ on an EC2 we don’t have access to JAVA_HOME environmental variable nor the local file system, hence we can’t override the emulator settings.

    Android Emulator Setup

    1. From Android Studio open the Device Manager.

    Click the Edit button for the emulator that you want to use.

     In the Virtual Device Configuration window, click Show Advanced Settings.

     In the Camera section select VirtualScene from the drop down.

    Click Finish.

    Sauce Labs

    Available for Android and iOS physical devices only. There’s support for native apps only.

    The config file’s capabilities need to include the following field:

    "sauceLabsImageInjectionEnabled": "true"

    Sauce Labs' App Config

      Login into your Sauce Labs account.

      Go to App Management.

      Click the Settings button for the app you want to use.

      Turn the Image Injection switch on.

       

      Supported APIs

      Android System Camera

      For Android devices, there are multiple ways toor capture an image,image.

      Validating asOCR, describedbarcode, inQR code, document, or visual-recognition behavior.Replacing manual camera interaction with a repeatable test input.Confirming how the Androidapplication Camerahandles APIvalid, developerinvalid, documentation.or AIQedge-case supportsimage files.

      Validation workflow

      1. Select a small set of approved test images with known expected results.
      2. Configure the following:mobile
          environment
        • ACTION_IMAGE_CAPTURE Opensso the systemapplication camera and notifies the calling app when the image is taken.

        camera2 API: Everything is configured and handled from within the app.

        cameraX: Leverages the capabilities of camera2, but uses a simpler, use case-based approach that is lifecycle-aware.

        Camera API (deprecated): partially supported. As with camera2, everything is handled in the app itself. QR Code readers often use Camera#setPreviewCallback. We pass the injected image to this method, but the rest of this deprecated API is not supported. UI Elements will not likely displayreceives the injected image.

        Add

        iOS System Camera

        For iOS devices, the camera can be configured with different outputs. AIQ supports the following:

          AVCapturePhotoOutput: for capturing still images. The results are received via the AVCapturePhotoCaptureDelegateand the method captureOutput:didFinishProcessingPhoto:error: The other methods in this delegate are either deprecated or handle live photos, which we don't support.

          AVCaptureVideoDataOutput: for capturing video frames and processing them. The frames are received via AVCaptureVideoDataOutputSampleBufferDelegate and the method captureOutput:didOutputSampleBuffer:fromConnection:.

          AVCaptureMetadataOutputfor reading QR-Codes. The QR Codes are passed to the app via captureOutput:didOutputMetadataObjects:fromConnection:. We are detecting the AVMetadataMachineReadableCodeObject and QR Codes are part of that.

          Sauce Labs documentation is available here.

          BrowserStack

          The config file’s capabilities need to include the following field:

          "browserstack.enableCameraImageInjection": "true"

          Supported APIs

          Camera image injection is supportedassertions for the followingscreen, Camerauploaded APIs.file, Checkextracted withtext, youror appdownstream development team to get more details aboutrecord.

          Run the Cameratest APIson yourthe apprequired uses.device

          OS

          OS version

          Supported APIs

          iOS

          iOS 13profile and above

          review evidence.

          didFinishPickingMediaWithInfoData-safety APInote: ofDo UIImagePickerControllernot iOSinject SDKreal classcustomer fordocuments, capturingIDs, anor image.private Forimages moreunless details,the pleasecustomer checkhas Appleexplicitly documentation.approved that test data.

          AVCapturePhoto iOS SDK class for receiving captured photos from AVCapturePhotoOutput API. For more details, please check Apple Documentation.

          jpegStillImageNSDataRepresentation of AVCaptureStillImageOutput iOS SDK class. For more details, please check Apple documentation.

          Android

          Android 6 and above

          android.hardware.camera.PreviewCallback API for API level 1-20

          android.hardware.camera2.CameraManager, android.hardware.camera2.CameraDevice, android.hardware.camera2.CameraCharacteristics, android.hardware.camera2.CameraCaptureSession, android.hardware.camera2.CaptureRequest, android.media.ImageReader APIs for API level >=21

          Camera Intent API

          Browser Stack full documentation here.

          LambdaTest

          The config file’s capabilities need to include the following field:

          "enableImageInjection": "true"

          LambdaTest App Setup

          1. Login to your LambdaTest account.

          2. Go to App Testing under Real Devices.

          3. Hover the Settings icon and toggle the Image Injection switch on.

          Supported APIs

          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.

          OS

          Devices

          Supported APIs

          iOS

          iOS 13 and higher

          didFinishPickingMediaWithInfo API of UIImagePickerController iOS SDK class for capturing an image. For details, please check Apple documentation.

          AVCapturePhoto iOS SDK class for receiving captured photos from AVCapturePhotoOutput API. For details, please check Apple Documentation.

          Android

          Android 9 and higher

          CameraX API is used. For details, please check CameraX Documentation

          Camera API is used. For details, please check this link.

          Camera2 API is used. For details, please check this link.

          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 this link.

          LambdaTest full documentation here.


          Last updated: October 01,8, 20242026

          If you have any feedback on this topic, please contact us at documentation@appvance.ai