Page tree
Skip to end of metadata
Go to start of metadata


Description

The command allows users to test applications that use the camera on a mobile device.

The command injects an image file to the camera preview screen.

Parameters

  • Picture Path - The image file full path, this image will switch the original camera preview screen.

iOS Devices

This feature is supported only on Instrumented applications and on device with iOS 9 and above (For manual instrumentation please see additional information).

Supports only *.jpeg , *jpg or *.png file types.

Usage

The user would like to upload an image file that will be used by his camera feature instead of taking a real photo with the device's camera.

Step 1: Launch your application (here we demonstrate on the PhotoPicker app). 

             


Step 2: Run simulateCapture() with your image file (see example in the 'Code Example' section).

               

Step 3: Click on the camera icon, this will launch the camera preview screen with your image.

                

Step 4: To open the camera preview screen without your uploaded image you need to run simulateCapture() command again with empty parameter (meaning: erase the text you wrote as a path and make sure nothing else is written there) or restart your application.

              





QR Codes

Simulating QR Codes is supported by SimulateCapture command.

Note: the image of the QR Code won't be shown at the camera preview screen.





Android Devices

Works from android 4.3 and up!

Usage

When the user starts the app, he will see the real preview of the camera as usual until he will send the mock image.
When the client sends the mock image to the camera, the preview will change to show the image.


Step 1:

Add the following line to the app.properties file:

android.instrumentation.camera = true

Then restart SeeTest Automation.

Or:

From your code environment, use setProperty command with  android.instrumentation.camera = true  ,and then install with instrument=true.


Step 2:

Start the application in instrumented mode, and navigate to the activity which includes the camera preview.


Step 3:

Add the 'SimulateCapture' command to the test script, with a path to the image file, and run the script.

The selected image will be shown on the device reflection screen, instead of the real camera preview.


Code Examples

Java Example
 client.simulateCapture("C:\\images\\image.jpg");
C# Example
 client.SimulateCapture("C:\\images\\image.jpg");
VBScript Example
client.SimulateCapture("C:\\images\\image.jpg")



Python Example
 self.client.simulateCapture("C:\\images\\image.jpg")
Perl Example
 $client->simulateCapture("C:\\images\\image.jpg");

  • No labels