Skip to main content

Camera Image Injection

This document provides details about the camera image injection feature of Katalon TestCloud.

Camera image injection supports the following systems and interfaces:
  • iOS: 13 or higher.

    • The didFinishPickingMediaWithInfo class of UIImagePickerController iOS SDK class for capturing an image. See: Apple documentation.

    • The AVCapturePhoto iOS SDK class for receiving captured photos from AVCapturePhotoOutput class. See: Apple Documentation.

  • Android: 9 or higher.

One limitation of testing with cloud-based mobile devices is the ability to capture images. Camera image injection tackles this issue by simulating the action of taking images through a mobile application.

Some common use cases of camera image injection are:
  • Scanning a check for a banking application.
  • Scanning a QR code.
  • Taking a user profile picture.
  • Taking a photo and store in a gallery app.

To perform image injection, you need to specify the desired capability, prepare the images and declare the keyword. Follow these steps:

  1. Open your project in Katalon Studio and go to Project Settings > Desired Capabilities > Remote. Add the boolean property enableImageInjection=true.
    Katalon Studio, Project Settings, Desired Capabilities
  2. Save the images that are required for image injection in the Data Files/TestCloud folder of Katalon Studio project.

    The images must be in PNG, JPG, or JPEG formats, and does not exceed 4.5 MB.

    Katalon Studio Data Files/TestCloud
  3. In the Keywords folder, create and declare the CameraImageInjectionExecutor class under package com.katalon.testcloud.
    Katalon Studio - custom keyword CameraImageInjectionExecutor declaration
    public class CameraImageInjectionExecutor {
    /**
    * Injects an image from "Data Files/TestCloud" into the camera for testing purposes.
    *
    * @param fileName The name of the file to inject.
    * @return true if the injection was successful, false if there was an error.
    */
    @Keyword
    def injectImage(String fileName);

    /**
    * Checks whether a file with the given name exist in "Data Files/TestCloud".
    *
    * @param fileName The name of the file to check.
    * @return true if the file exists, false otherwise.
    */
    @Keyword
    def exist(String fileName);
    }
You can now use the keyword to inject images.