Photo and video simulation

Mobile Center's photo and video simulation lets you simulate the capturing of images and videos.

About photo and video simulation

Using Mobile Center's photo and video simulation, you specify the image or video to use instead of the actual output of the camera. You can then use these images or videos to test your app.

When you perform simulation of a photo, Mobile Center replaces the camera output with the selected file, when you tap the Take a picture button on the device. When you perform simulation of a video, Mobile Center replaces the camera output with the selected file, when you end the video recording session on the device.

If you are recording test code, you will notice two steps: a file upload step and a simulation step.

Performing simulation

To use photo and video simulation, make sure that you have a remote view of a device and that the Control Panel is open. For details, see Device control panel.

Note: Photo and video simulation is supported only for packaged iOS and Android apps.

  1. Activate simulation mode.

    1. For a photo, click the photo simulation button .
    2. For a video, click the video simulation button .

    The Simulate Photo or Simulate Video 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 prepare all of the image and video files for your test at once. See Guidelines for photo and video simulation for information on the valid file types and sizes.
  4. If you have uploaded multiple files, click the photo or video simulation button and select the file to use the next time your device takes a picture or video. Click OK to register the new selection.

    Tip: If you do not change your selection, the test will continue to use the same photo or video each time you take a picture or record a video.

  5. Navigate on your device to the page from where you will be taking a picture or video.
  6. Click the button to take a picture, or click the Start Recording button, proceed with your recording session and click Stop.
  7. Repeat the above steps for all of the images or videos you want to replace.
  8. To deactivate simulation, click the photo or video simulation buttons, select the No Simulation box, and click OK.

    When simulation mode is active, the photo or video simulation buttons are displayed in a frame in the remote view's Control Panel.

Back to top

Guidelines for photo and video simulation

When using photo and video simulation for replacing images or videos, follow these guidelines:

  • The maximum number of files you can download on a device is 100.
  • The files should not consume more than 50% of the device's free disk space.
  • The supported image formats are: JPG, GIF, PNG, and BMP. iOS also supports TIF files. The uploaded TIF files may display as broken images, but they can still be used for simulation.
  • The supported video formats are: For Android: 3GP, MP4, and MKV. For iOS: MOV, MP4, and M4V.
  • 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.
  • Photo and video simulation is supported for the standard static camera and video mechanisms. Simulation may not be possible for apps that utilize a camera for scanning areas or prepare images for further processing or animations.
  • Simulation may not be possible if you customize the built-in camera settings.
  • On Android devices, set the saveToPic parameter to true (false by default) in order to save the images or videos 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

Photo and video simulation with Appium

You can implement photo and video simulation in your Appium scripts, utilizing the REST API reference for Mobile Center.

The following is a java code example of an implementation.

The first section contains all of the required import statements.

package com.hp.test.integration.e2e.ios;


import com.jayway.restassured.response.Response;

import org.apache.http.HttpStatus;

import org.testng.Assert;

import org.testng.annotations.Test;


import java.util.*;

The next section contains the script's actions.

public class AppiumSensorSimulationITCase extends AbstractIosAppiumTest{

private static final String mediaRestBase = "/rest/v2/media";

private static final String mediaFileReferenceName = "test";



protected void setInitialCapabilities() {

addCapability("bundleId", "com.hp.testapp.UICatalogINJ");




public void test_sensorSimulation() {


Map<String, Object> params = new HashMap<>();

List<String> sensorDataList = new ArrayList<>();


params.put("sensorData", sensorDataList);

params.put("simulateCount", 1);

Object response = wd.executeScript("", params);

Assert.assertTrue(response.toString().contains("message") && response.toString().contains("success"));



private void uploadMediaFileWithReferenceName(String referenceName) {

MediaFileProperties mediaFileProperties = new MediaFileProperties();



Response response1 = givenMCAdmin()



String jobId = null;

try {

jobId = (String)(((Map)((List)(response1.getBody().as(Map.class).get ("data"))).get(0)).get("id"));

} catch (Exception e) {



.multiPart("mediaFile", new File(AppiumSensorSimulationITCase.class.getClassLoader().getResource("test.jpg").getPath()))

  .multiPart("mediaFileProperties", mediaFileProperties, "application/json")

  .queryParam("jobId", jobId)






private class MediaFileProperties {

private String referenceName;

private boolean saveToGallery;

private String link;


public String getLink() {

    return link;


public void setLink(String link) { = link;


public String getReferenceName() {

       return referenceName;


public void setReferenceName(String referenceName) {

      this.referenceName = referenceName;


public boolean isSaveToGallery() {

      return saveToGallery;


public void setSaveToGallery(boolean saveToGallery) {

      this.saveToGallery = saveToGallery;




Back to top

See also: