Start activity (FR)

Perfecto Command

mobile:activity:open

Purpose

Starts an Android activity on the device. Android applications are composed of a series of "Activity" units. Each Activity presents a UI screen that allows users to perform some part of the application, such as call a number, take a photo, send an email, or view a map. When testing the application, it may be desirable to start the application execution from a specific Activity, rather than the initial Activity (usually referred to as the .Main).

Applications can be large and complex, written by many development teams. The start activity and sync activity commands enable a tester to start and sync a specific activity on the device and decreases the time it takes to write a test, allowing more coverage in a dynamic environment where time to develop tests is short.

Parameters

Name Type Possible Values Description
package (Mandatory) String The Android application identifier.
Example - com.sec.android.app.camera
activity (Mandatory) String The activity name.
Example - .Camera
action String The intent action name.
category String The intent category name.
flags String The intent flags name.
arguments String The intent arguments name.
Note:

Use the mobile:device:info function while running the activity, to retrieve the currentActivity and currentPackage values to use with this function.

The intent is the normal Android mechanism to pass information between application activities.

Return Value

String - "OK" or "Failed"

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> params = new HashMap<>();
params.put("package", "com.google.android.keep");
params.put("activity", ".BrowseActivity");
String model = (String) driver.executeScript("mobile:activity:open", params);
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("package", "com.google.android.keep");
pars.Add("activity", ".BrowseActivity");
String model = (String) driver.ExecuteScript("mobile:activity:open", pars);