Keyboard Service

Learn how to use BELLATRIX android keyboard service.

Example

public class KeyboardServiceTests extends AndroidTest {
    @Test
    public void testHideKeyBoard() {
        var textField = app().create().byIdContaining(TextField.class, "left_text_edit");
        textField.setText("");

        app().keyboard().hide();
    }

    @Test
    public void pressKeyCodeTest() {
        app().keyboard().pressKey(AndroidKey.HOME);
    }

    @Test
    public void longPressKeyCodeTest() {
        app().keyboard().longPressKey(AndroidKey.HOME);
    }
}

Explanations

BELLATRIX gives you an interface for easier work with device’s keyboard through the keyboard method.

app().keyboard().hide();

Hides the keyboard.

app().keyboard().pressKey(AndroidKey.HOME);

Press the Home button.

app().keyboard().longPressKey(AndroidKey.HOME);

Long press the Home button.