Skip to main content

Reference

For each supported domain Pumpo Number Five proposes a domain specific language that can be used to:

  • defining page objects mostly in a declarative way
  • passing commands to the client host applications (called proxies) directly from tests

An example of declarative page object definition in the Web domain is the following example from our starter kit:

@Navigate("https://www.google.com")
@Wait(value = GoogleSearchPage.ACCEPT_BUTTON_XPATH, by = Lookup.XPATH)
public interface GoogleSearchPage extends WebDriverAccessor {

String ACCEPT_BUTTON_XPATH = "//button[2]";

@Click(value = ACCEPT_BUTTON_XPATH, by = Lookup.XPATH)
GoogleSearchPage AcceptCookies();

@SetValue(value = "q", by = Lookup.NAME)
GoogleSearchPage typeIntoSearchBox(String term);

@ExtendedAction
default GoogleSearchPage submit() {
getDriver().findElement(By.name("q")).submit();
return null;
}

GoogleSearchResultsPage onSearchResultsPage();

}

The declarative nature can be seen e.g.:

  • The URL of the landing page is specified using the annotation @Navigate. Pumpo Number Five handles all what is required to navigate to the page until elements specified with the Wait annotation are visible.
  • The action called AcceptCookies is defined solely using the annotation @Click with as attribute the XPATH of the element to click.
  • Entering a value in the form input field with name q is done thanks to an action here called typeIntoSearchBox and is declared using the annotation @SetValue.
  • When necessary because the library does not propose a required action, custom code can be written to define additional actions using the @ExtendedAction annotation as for the method submit.

The test can then be written as following lines:

firefox
.openGoogleSearchPage()
.AcceptCookies()
.typeIntoSearchBox("pumpitup")
.submit()
.onSearchResultsPage()
...

Notice the last line that switches to the next page object without breaking the fluent nature of the test.

So for each domain there is a set of actions or/and annotations which this reference is all about.