Skip to main content

SimulateCapture

Description

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

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

Parameters

NameValueDescription
Picture PathPath in String formatThe image file full path, this image will switch the original camera preview screen.







In Appium Server (Appium Open Source) file unique name can be provided in the following format:



cloud:file_unique_name



Using The File Repository

Usage

The command can be used to Simulate Camera capture action, this command needs the Simulate Capture libraries when an application is uploaded.

info

Replace <server> with the appropriate URL.

Example

Simulate Capture - Using file from file repository

// File with unique name my_image must exist in file repository
driver.executeScript("seetest:client.simulateCapture", "cloud:my_image")

Simulate Capture - using local file

DesiredCapabilities dc = new DesiredCapabilities();
driver = new AndroidDriver(new URL("<server>"), dc);
seetest = new SeeTestClient(driver);
dc.setCapability(MobileCapabilityType.UDID, "deviceid");

...
...

// this command simulates
seetest.simulateCapture("C:\\images\\image.jpg");
info

To work with this feature, the app must require and acquire the permission"android.permission.WRITE_EXTERNAL_STORAGE" before attempting to simulate capture

info

For SeeTest local, android 9+, a user should make sure that the following shell commands are run before running the application:

adb shell settings put global hidden_api_policy_pre_p_apps 1
adb shell settings put global hidden_api_policy_p_apps 1