Press key (FR)

Perfecto Command

mobile:presskey

Purpose

Clicks on a single or sequence of special device keys (either control or keyboard). You can hover over the device keys to identify them, then enter the Keys parameter according to the required syntax.

Common keys include: LEFT, RIGHT, UP, DOWN, OK, BACK, MENU, VOL_UP, VOL_DOWN, CAMERA, CLEAR

Important: The listed keys are not necessarily supported by all devices. The available keys depend on the device.

Presskey will always press the keyboard keys according to the default layout configuration.

To press on Enter/Submit/Search, as the Keys parameter value, enter the following (supported on Android and iOS):

  • KEYBOARD_GO
  • KEYBOARD_SEARCH
  • KEYBOARD_SEND
  • KEYBOARD_NEXT
  • KEYBOARD_DONE
  • KEYBOARD_PREVIOUS
  • KEYBOARD_ENTER
  • KEYBOARD_SUBMIT

To activate Siri on devices running 10.3 or later and configured for the XCUITest Framework, use the value LONGHOME.

Parameters

Name Type Possible Values Description
keySequence String

OK |
MENU |
HOME |
BACK |
LEFT |
RIGHT |
UP |
DOWN |
VOL_UP |
VOL_DOWN |
CAMERA |
CLEAR |
APP_SWITCH I
LONGHOME

(Required) The physical device keys to press. It is possible to select a sequence of comma separated keys.
To define a long key press, use a colon follow by the time in milliseconds.
Example -
END:3000
To embed a wait as part of the sequence, use WAIT= followed by the time in milliseconds.
Example -
WAIT=2000
For multiple key presses, use an asterisk. Example -
3*OK
This is the same as OK,OK,OK

Example - OK,WAIT=2000,2*DOWN,OK:3000

Note: For iOS, the only supported values are HOME and LONGHOME.

keypad String
Specify the logical name of the virtual keypad to be used. A virtual keypad is defined as the keypad popping up to the user when inputs are required.
This parameter is operational only on selected touch-enabled platforms.

Return Value

None

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> params = new HashMap<>();
params.put("keySequence", "BACK");
driver.executeScript("mobile:presskey", params)
Copy

JavaScript sample

var params = {
    "keySequence":"OK"    }
    browser.executeScript('mobile:presskey', params);
Copy

To activate Siri

Map<String, Object> params = new HashMap<>();
params.put("keySequence", "LONGHOME");
driver.executeScript("mobile:presskey", params)
Copy

C# sample

 Dictionary<String, Object> pars = new Dictionary<String, Object>();
 pars.Add("keySequence", "BACK");
 driver.ExecuteScript("mobile:presskey", pars);