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"); radio.select(); assertTrue(radio.isSelected());
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); myInput.select(); assertTrue(myInput.isSelected());
Another example, for checking a checkbox:
CheckBox checkbox = CheckBoxes.checkBoxWithProperties(ElementProperties.isNthSibling(3)); checkbox.check();; assertTrue(checkbox.isChecked()); assertThat(checkbox.toString(), equalTo("checkbox, that is in place 3 among its siblings"));
Inputs¶
Inputs.inputForLabel
- input referenced by the label element with the given textInputs.inputFollowedByUnlabeledText
- it is followed by text, without a label element.Inputs.genericFormInputAfterField
- a generic, reasonable, guess that works for many formsInputs.genericFormInputBeforeField
- a generic, reasonable, guess that works for many formsInputs.clearInput
- clear the input. If it is unsuccessful, it throws an exception.Inputs.clearInputNonStrict
- clear the input as much as it canInputs.changeInputValue
- replace any existing value in the input with a new oneInputs.selectInFieldWithLabel
- select an option in a select elementInputs.changeInputValueWithEnter
- update the value and send ENTER
Checkboxes¶
CheckBoxes.checkBoxWithLabel
CheckBoxes.checkBoxWithProperties
checkbox with a list of propertiesCheckBox.isChecked
- is this checkbox checked?CheckBox.check
CheckBox.uncheck
Radio Buttons¶
RadioInputs.withTextUnknownDOM
- there is some text next to the input, but the DOM structure is unknownRadioInputs.withLabeledText
RadioInputs.withUnlabeledText
RadioInputs.withProperties
RadioInput.isSelected
RadioInput.select