Skip to content
Taisiia-Kozlova edited this page Nov 7, 2017 · 5 revisions

Button – simple graphic element that triggers some event when being clicked on.

Example:

Button

The actions available are limited by nature of buttons. In most cases, you will just wish to click on them.

Also, sometimes you might want to get the text from the button. In JDI this can be easily done with a simple method getText() that retrieves button text, no matter which tag of the element holds the text-value.

Here is the list of available methods.

Method Description Return Type
click() Click on button void
getText() Retrieve button text String

Initialization:

@FindBy(xpath = "//button xpath")
public Button button;

Action > Examples:

@Test
public void clickButtonExample() {
    button.click();
}


@Test
public void getButtonTextExample() {
    String expected = "button text";
    String actual = button.getText();
    Assert.assertEquals(actual, expected);
}

See more examples on GitHub

Clone this wiki locally