High-Level API

The purpose of the high level API package is to provide a simplified API to common interactions with elements of type inputs, radio buttons, checkboxes, dropdowns etc.

The examples below are from the integrations tests of dollarx.

It is less flexible and sometimes suboptimal, but its value is a higher level abstraction.

For example:

RadioInput radio = RadioInputs.withLabeledText("Option 123");

The code above does not require the developer to know the exact organization of the DOM. It will find it by itself (on a best effort basis), assuming there is a “label” element with the text “Option 123” that corrsponds to the input

If you don’t even know if therer is a “label” element for this input, but just know that there is some text the correspond to this field, and you want to let dollarx figure out the right structure, you can do it with the higher level function withTextUnknownDOM():

RadioInput myInput = RadioInputs.withTextUnknownDOM("Female", 5, TimeUnit.SECONDS);

Another example, for checking a checkbox:

CheckBox checkbox =  CheckBoxes.checkBoxWithProperties(ElementProperties.isNthSibling(3));
assertThat(checkbox.toString(), equalTo("checkbox, that is in place 3 among its siblings"));