-
Notifications
You must be signed in to change notification settings - Fork 7
Conditions and how to use them
The following conditions are available for all components:
- READONLY
- EDITABLE
- REQUIRED
- ENABLED
- DISABLED
- VISIBLE
- HIDDEN
Conditions are described in the com.haulmont.masquerade.Conditions
.
Add the following code to the test class to use these conditions:
import static com.haulmont.masquerade.Conditions.*
Note, that some components may have unique conditions, thus, each component class is provided with Javadoc containing a full list of supported conditions.
Selenide provides a number of methods for checking component conditions:
should(Condition);
shouldNot(Condition);
shouldBe(Condition);
shouldNotBe(Condition);
shouldHave(Condition);
shouldNotHave(Condition);
When choosing a method to use, consider the perception of the resulting code. It is more preferable if code lines are easy to read, like common phrases, e.g.:
$c(PickerField, byCubaId('+CollectionString'))
.shouldHave(Conditions.value('one, two'));
$c(LookupPickerField, byCubaId('+CollectionString'))
.shouldBe(VISIBLE);
$c(CheckBox, byCubaId('rememberMeCheckBox'))
.shouldBe(CHECKED);
$c(TextField, byCubaId('email))
.shouldNotHave(Conditions.value('value');
$c(DateField, byCubaId('endDateField'))
.shouldNotBe(REQUIRED);
Assertions work as explicit expectations (explicit waits). They expect a certain condition to be satisfied (visible, enabled, text ("some text")
) until the particular timeout (Configuration.timeout
value, which is set by default to 4000 milliseconds) expires.
You can use assertions explicitly to reach the desired state of elements before the action, e.g. :
$c(Button, 'create').shouldBe(ENABLED).click();