QR code and barcode simulation

Mobile Center's simulation lets you simulate the scanning of QR codes and barcodes.

About QR code and barcode simulation

Using Mobile Center's QR code and barcode simulation, you specify the image to use instead of the actual scan of the device. You can then use these images to test your app.

When you perform simulation of a QR code, Mobile Center replaces the code scanned by the camera, with the selected file.

Performing QR code and barcode simulation

The QR code and barcode simulation is available from the Device control panel for exploratory testing, and from the UFT/LeanFT testing tools.

Note: Simulation is supported only for packaged iOS and Android apps. iOS should be 11.1 or higher.

  1. Activate simulation mode, by clicking the QR code and barcode simulation button .

    The Simulate QR Code or barcode scan dialog box opens.

  2. In the Simulate dialog box, provide a file, one at a time, in one of the following ways:

    1. Paste in the URL of the image or video file.
    2. Browse for a file on a local or network machine.
    3. Drag and drop a file (not supported for UFT).
  3. You can add all of your QR code or barcode image files at this stage, even if you do not intend to use them for the current test. See QR code and barcode simulation for information on the valid file types and sizes.
  4. If you have uploaded multiple files, click the simulation button and select the file to use the next time your device scans a code. Click OK to register the new selection.

    Tip: If you do not change your selection, the test will continue to use the same image each time you scan a code.

  5. Navigate on your device to the page from which you will be scanning the code.
  6. Repeat the above steps for all of the scans you want to replace.
  7. In exploratory mode, when simulation mode is active, the QR code and barcode simulation button is displayed within a frame.

Back to top

Guidelines for QR code and barcode simulation

When using QR code and barcode simulation for replacing images, follow these guidelines:

  • The maximum number of files you can download on a device is 100.
  • Make sure that the QR code you are simulating is clear, centered, and not bent.
  • The files should not consume more than 50% of the device's free disk space.
  • The supported image formats are: JPG, GIF, PNG, BMP, and WBMP.
  • Recording of QR codes and bar codes is not supported for testing tools, such as UFT, Sprinter, and so forth; replay is supported.

    To replay on iOS or Android, add the SimulateBarcodeByImage method. For example:

    Device("Device").UploadMedia "CODE39.png", "Z:\QRCode_Image\Scandit_Demo\PNG_File\CODE39.png"

    Device("Device").App("SimpleSample").SimulateBarcodeByImage "CODE39.png"

    On iOS, you can also use the SimulateBarcodeByData method. For example:

    Device("Device").App("com.hp.hmc.ScanditSample").SimulateBarcodeByData "OK","AZTEC"

  • When working in the remote device view with exploratory testing, you cannot deactivate the simulation, once it’s been activated.
  • Simulation is only supported for Scandit Barcode Scanner SDK, Google Mobile Vision, and Google Zxing barcode scanning.
  • When working with Android 6.0 or later, you must have permission to access the device's external storage.
  • For Android, this simulation is only supported for apps using the YUV NV21 camera preview image format.
  • For Android, this simulation is only supported for apps using the Android Camera API, but not the Camera 2 or Camera NDK APIs.

    For iOS, the native Barcode and Qr Code API is supported.

  • For Android, simulation may not be possible if you customized the built-in camera settings.
  • The maximum upload file size for images is 5 MB. The maximum upload size for videos is 20 MB with 1.5 GB of free memory for Android devices, and 40 MB for iOS devices.
  • The uploaded files are only valid for the current session. Once the test or remote view session is finished, the files will be erased.
  • On Android devices, set the saveToPic parameter to true (false by default) in order to save the image to a subfolder in the device's photo gallery. For example, modify the recorded step:

    Device("Device").UploadMedia "sample.png","C:\sample.png"


    Device("Device").UploadMedia "sample.png","C:\sample.png",True

Back to top

See also: