Lock Screen (FR)

Perfecto Command

mobile:screen:lock

Purpose

Locks the device screen for a specified number of seconds. Check instantly how your app behaves when the screen is locked.

Limitations

The following limitations apply:

  • mobile:screen:lock does not work on real iOS 17 devices with StandBy mode enabled. To be able to use this function on a real iOS 17 device that is locked, disable StandBy mode (under Settings > StandBy).

  • On mobile devices using the enhanced video solution, the 'Lock for duration' feature is not currently supported. If you're unsure which video solution is in use, check the clock on the display. If the background behind the clock is not red and the time shown is 9:41, the previous video solution is being used. The earlier solution does support the 'Lock for duration' feature.

Parameters

Name Type Possible Values Description
timeout Integer Time, in seconds, to lock device (default: 10)

Return Value

OK - if successful

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> param = new HashMap<>();
param.put("timeout", "3");
driver.executeScript("mobile:screen:lock", param);
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("timeout", "3");
driver.ExecuteScript("mobile:screen:lock", pars); 
Copy

Appium equivalent

driver.lockScreen(3);