Package com.vaadin.browserless
Class ElementConditions
java.lang.Object
com.vaadin.browserless.ElementConditions
A collection of commons predicates to be used as
ComponentQuery
conditions.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionariaLabelContains(String text) Checks if the component'saria-labelattribute contains the given text.containsText(String text) Checks if text content of the component contains the given text.containsText(String text, boolean ignoreCase) Checks if text content of the component contains the given text.hasAriaLabel(String ariaLabel) Checks if the component has itsaria-labelattribute set to exactly the given value.hasAttribute(String attribute) Checks if the given attribute has been set on the component.hasAttribute(String attribute, String value) Checks if the given attribute has been set on the component and has exactly the given value.Checks if the component is labelled by exactly the given text.hasNotAttribute(String attribute) Checks if the given attribute has not been set on the component.hasNotAttribute(String attribute, String value) Checks if the given attribute has been set on the component or has a value different from given one.labelContains(String text) Checks if the component's label contains the given text.
-
Method Details
-
containsText
Checks if text content of the component contains the given text. Input text is compared with value obtained either byHasText.getText(),Element.getText()if element is a text node, or the normalized version ofHtml.getInnerHtml(). In all other casesElement.getTextRecursively()is used, but in this case text from nested elements is concatenated without space separators. The comparison is case-sensitive. ForHtmlcomponents the innerHTML tags are stripped and whitespace is normalized and trimmed. For example, given HTML
the text that will be checked will be Hello there now!.Hello there now!
- Parameters:
text- the text the component is expected to have as its content. Not null.- Returns:
- this element query instance for chaining
- See Also:
-
containsText
Checks if text content of the component contains the given text. Input text is compared with value obtained either byHasText.getText(),Element.getText()if element is a text node, orHtml.getInnerHtml(). In all other casesElement.getTextRecursively()is used, but in this case text from nested elements is concatenated without space separators. ForHtmlcomponents the innerHTML tags are stripped and whitespace is normalized and trimmed. For example, given HTML
the text that will be checked will be Hello there now!.Hello there now!
- Parameters:
text- the text the component is expected to have as its content. Not null.ignoreCase- flag to indicate if comparison must be case-insensitive.- Returns:
- this element query instance for chaining
- See Also:
-
hasAttribute
Checks if the given attribute has been set on the component. Attribute names are considered case-insensitive and all names will be converted to lower case automatically.- Parameters:
attribute- the name of the attribute, not null- Returns:
- true if the attribute has been set, false otherwise
-
hasAttribute
Checks if the given attribute has been set on the component and has exactly the given value. Attribute names are considered case-insensitive and all names will be converted to lower case automatically.- Parameters:
attribute- the name of the attribute, not nullvalue- expected value, not null- Returns:
- true if the attribute has been set, false otherwise
-
hasNotAttribute
Checks if the given attribute has not been set on the component. Attribute names are considered case-insensitive and all names will be converted to lower case automatically.- Parameters:
attribute- the name of the attribute, not null- Returns:
- true if the attribute has not been set, false otherwise
-
hasNotAttribute
Checks if the given attribute has been set on the component or has a value different from given one. Attribute names are considered case-insensitive and all names will be converted to lower case automatically.- Parameters:
attribute- the name of the attribute, not nullvalue- value expected not to be set on attribute, not null- Returns:
- true if the attribute is not set or has a value different from given one, false otherwise
-
hasLabel
Checks if the component is labelled by exactly the given text. A component is considered labelled by a text when either:- its
labelproperty (read byHasLabel.getLabel()) equals the text, or - some
<label for="componentId">element elsewhere in the UI has that text as its (recursive) content.
NativeLabel(or any<label>element) targets an input via theforattribute.- Parameters:
label- the expected label, not null
- its
-
labelContains
Checks if the component's label contains the given text. The label is read in the same way ashasLabel(String)(component'slabelproperty or a referring<label for="...">element). Comparison is case-sensitive.- Parameters:
text- substring to find in the label, not null
-
hasAriaLabel
Checks if the component has itsaria-labelattribute set to exactly the given value. Useful for components likeButtonthat don't expose alabelproperty but identify themselves to assistive technology viaaria-label.- Parameters:
ariaLabel- the expected aria-label, not null
-
ariaLabelContains
Checks if the component'saria-labelattribute contains the given text. Comparison is case-sensitive.- Parameters:
text- substring to find in the aria-label, not null
-