Press button operation

Press the specified key on the device's remote control. This operation is dedicated to devices featuring a remote control, such as TVs, set-top boxes or game consoles. When testing websites use Send text. Check the button VRC constants for the Suitest JavaScript API.


Press button basics

To perform this operation in the Suitest Test editor use the Press line:

Example lines pressing keys CHANNEL_UP, OK and DOWN
Example lines pressing keys CHANNEL_UP, OK and DOWN

To perform this operation in the Suitest JavaScript API use the Press command:

await suitest.press(suitest.VRC.CHANNEL_UP);
await suitest.press(suitest.VRC.OK);
await suitest.press(suitest.VRC.DOWN);

Press multiple buttons in a row

The Press button operation accepts multiple buttons that will be pressed one after the other. The button presses are sent to the device sequentially with a delay of around 1000 ms.

Press 3 different buttons in a row
Press 3 different buttons in a row

In JavaScript API:

await suitest.press([suitest.VRC.OK, suitest.VRC.UP, suitest.VRC.DOWN]);

Press button a specific amount of times with a specified frequency

You can send repeated button presses to the device with a particular frequency. You can use this for example to check if the app (or device) can handle many frequent key presses gracefully.

Press down 10 times every 100 ms
Press down 10 times every 100 ms

In JavaScript API use repeat and interval:

await suitest.press(suitest.VRC.DOWN)
    .repeat(10)
    .interval(100);

The frequency parameter is expected to be between 0.01 seconds and 3600 seconds.

Device dependent: The input processing capabilities vary across devices. You may therefore experience a situation where the device is stalling or skipping key input altogether. This is especially true with a lower-end set-top boxes. Most TV's and set-top boxes will not be able to recognize key presses sent every ~250 ms or less.

When multiple keys are specified the entire sequence will be repeated the specified number of times. You can use this, for example, to move through the list of items in a zig-zag pattern or for pressing Enter and Back a number of times to test the application's stability.

Keep pressing button(s) until a condition is met

You can combine the press operation with an Assertion and instruct Suitest to keep pressing the button(s) until a specific condition is met.

Press forward until a video position is reached
Press forward until a video position is reached

In JavaScript API:

const video = suitest.assert.video();
const playedForTenSeconds = {
    name: suitest.PROP.VIDEO_POSITION,
    val: "10",
    type: suitest.COMP.EQUAL_GREATER,
};

// press forward until the video progress is more than 10 seconds
await suitest.press(suitest.VRC.FORWARD).until(
    video().matches(playedForTenSeconds)
).repeat(15);

Press button(s) only if a condition is met

You can combine the Press operation with an Assertion and instruct Suitest to run this operation only if the condition is satisfied.

For instance, the application may pop up a dialog asking the user for their location the first time they use the app. The conditional button press can be used to reliably dismiss this dialogue.

Navigate to the element only if the element is visible
Navigate to the element only if the element is visible

In JavaScript API:

const {press, element, VRC, PROP} = suitest;

if (await element('element').exists()) {
    await press(VRC.RIGHT).until(
        element('element').matches(PROP.BORDER_COLOR, '#0000FF')
    ).repeat(10);

    await press(VRC.OK);
}