Run app in background (FR)

Perfecto Command

mobile:application:back

Purpose

Identifies the active application automatically, moves it to the background for the timeout defined, and then returns it to the foreground. You can check how your application behaves when coming back into foreground: Is your data saved? Is your session alive? Did your application crash?

Restriction: This command is supported for Android devices running version earlier than 5.0.

Parameters

Name Type Possible Values Description
timeout Integer
The time, in seconds, to run the current application as a background application. (Default 20 seconds)

Return Value

"OK" if successful, "Failed" otherwise.

Exceptions

None

Examples

Copy

Java sample

//declare the Map for script parameters
Map<String, Object> params = new HashMap<>();
  
params.put("timeout", "35");
String res = (String) driver.executeScript("mobile:application:back", params)
Copy

C# sample

//declare the Map for script parameters
Dictionary<String, Object> pars = new Dictionary<String, Object>();

pars.Add("timeout", "35");
String res = (String) driver.ExecuteScript("mobile:application:back", pars);