ElementProperties¶
-
public final class
ElementProperties
¶ Various constrains on
Path
instances, that are used with the methodsPath.that
andPath.and
.
Fields¶
hasChildren¶
-
public static final ElementProperty
hasChildren
¶ The element has 1 or more children (the opposite from hasNoChildren). Examples where it might be useful: an non-empty list, non-empty table, etc.
hasNoChildren¶
-
public static final ElementProperty
hasNoChildren
¶ The element has no children. Examples where it might be useful: an empty list, empty table, etc.
hasSomeText¶
-
public static ElementProperty
hasSomeText
¶ Element has non-empty text
isChecked¶
-
public static final ElementProperty
isChecked
¶ The element is checked
isDisabled¶
-
public static final ElementProperty
isDisabled
¶ The element is diabled
isEnabled¶
-
public static final ElementProperty
isEnabled
¶ The element is enabled
isLastSibling¶
-
public static final ElementProperty
isLastSibling
¶ The element is the last sibling (ie: last child) of its parent.
isOnlyChild¶
-
public static final ElementProperty
isOnlyChild
¶ The element is the only direct child of its parent. It has no siblings. For example: a table with a single row.
isSelected¶
-
public static final ElementProperty
isSelected
¶ The element is selected
Methods¶
contains¶
-
public static ElementProperty
contains
(Path... paths)¶ The given elements in the parameters list are contained in the current element
Parameters: - paths –
- a list of elements that are descendants of the current element
Returns: An element property that can be applied with Path::that
- paths –
hasAggregatedCaseSensitiveTextContaining¶
-
public static ElementProperty
hasAggregatedCaseSensitiveTextContaining
(String txt)¶ When aggregating all the text under this element, it contains the given substring. This condition is case sensitive.
Parameters: - txt – a substring of the aggregated, case sensitive, text inside the element
Returns: An element property that can be applied with Path::that
hasAggregatedCaseSensitiveTextEqualTo¶
-
public static ElementProperty
hasAggregatedCaseSensitiveTextEqualTo
(String txt)¶ When aggregating all the text under this element, it equals to the given parameter. This condition is case sensitive.
Parameters: - txt – the aggregated, case insensitive, text inside the element
Returns: An element property that can be applied with Path::that
hasAggregatedTextContaining¶
-
public static ElementProperty
hasAggregatedTextContaining
(String txt)¶ When aggregating all the text under this element, it contains the given substring (ignoring case)
Parameters: - txt – a substring of the aggregated, case insensitive, text inside the element
Returns: An element property that can be applied with Path::that
hasAggregatedTextEndingWith¶
-
public static ElementProperty
hasAggregatedTextEndingWith
(String txt)¶ When aggregating all the text under this element, it ends with the given substring (ignoring case)
Parameters: - txt – the suffix of the aggregated, case insensitive, text inside the element
Returns: An element property that can be applied with Path::that
hasAggregatedTextEqualTo¶
-
public static ElementProperty
hasAggregatedTextEqualTo
(String txt)¶ When aggregating all the text under this element, it equals to the given parameter. This condition is not case sensitive.
Parameters: - txt – the aggregated, case insensitive, text inside the element
Returns: An element property that can be applied with Path::that
hasAggregatedTextStartingWith¶
-
public static ElementProperty
hasAggregatedTextStartingWith
(String txt)¶ When aggregating all the text under this element, it starts with the given substring (ignoring case)
Parameters: - txt – the prefix of the aggregated, case insensitive, text inside the element
Returns: An element property that can be applied with Path::that
hasAncesctor¶
-
public static ElementProperty
hasAncesctor
(Path path)¶ Element is inside the given parameter
Parameters: - path – the ancestor of the current element
Returns: An element property that can be applied with Path::that
hasAnyOfClasses¶
-
public static ElementProperty
hasAnyOfClasses
(String... cssClasses)¶ Element that has at least one of the classes given
Parameters: - cssClasses –
- the class names to match to
Returns: a element property that can be applied with Path::that
- cssClasses –
hasAttribute¶
-
public static ElementProperty
hasAttribute
(String attribute, String value)¶
hasCaseSensitiveText¶
-
public static ElementProperty
hasCaseSensitiveText
(String txt)¶ Element has text equals to the given string parameter. The equality is case-sensitive.
Parameters: - txt –
- the text to match to (case sensitive)
Returns: a element property that can be applied with Path::that
- txt –
hasCaseSensitiveTextContaining¶
-
public static ElementProperty
hasCaseSensitiveTextContaining
(String txt)¶ The text in the element contains the given parameter. This condition is case=sensitive.
Parameters: - txt –
- the substring to match to (case sensitive)
Returns: An element property that can be applied with Path::that
- txt –
hasChild¶
-
public static ElementProperty
hasChild
(Path... paths)¶ Element is the parent of the given list of elements
Parameters: - paths –
- a list of elements that are children of the current element
Returns: An element property that can be applied with Path::that
- paths –
hasClass¶
-
public static ElementProperty
hasClass
(String className)¶ Has the class given in the parameter
Parameters: - className – the class the element has
Returns: An element property that can be applied with Path::that
hasClassContaining¶
-
public static ElementProperty
hasClassContaining
(String classSubString)¶ Element that has a class with name that contain the given parameter
Parameters: - classSubString – a string that should be contained in the class
Returns: An element property that can be applied with Path::that
hasClasses¶
-
public static ElementProperty
hasClasses
(String... cssClasses)¶ Element that has all of the given classes
Parameters: - cssClasses –
- the class names to match to
Returns: a element property that can be applied with Path::that
- cssClasses –
hasDescendant¶
-
public static ElementProperty
hasDescendant
(Path... paths)¶ The given elements in the parameters list are contained in the current element
Parameters: - paths –
- a list of elements that are descendants of the current element
Returns: An element property that can be applied with Path::that
- paths –
hasId¶
-
public static ElementProperty
hasId
(String id)¶ Element has ID equals to the given parameter
Parameters: - id –
- the ID to match to
Returns: a element property that can be applied with Path::that
- id –
hasNChildren¶
-
public static ElementPropertyWithNumericalBoundaries
hasNChildren
(Integer n)¶ The element has n direct children
Parameters: - n – the number of children
Returns: a element property that can be applied with Path::that
hasName¶
-
public static ElementProperty
hasName
(String name)¶ Element with a “name” attribute equal to the given parameter. Useful for input elements.
Parameters: - name – the value of the name property
Returns: a element property that can be applied with Path::that
hasNonOfTheClasses¶
-
public static ElementProperty
hasNonOfTheClasses
(String... cssClasses)¶ Element that has none of the given classes
Parameters: - cssClasses –
- a list of class names, none of which is present in element
Returns: An element property that can be applied with Path::that
- cssClasses –
hasParent¶
-
public static ElementProperty
hasParent
(Path path)¶ Element is direct child of the element matched by the given parameter
Parameters: - path –
- the parent of the current element
Returns: An element property that can be applied with Path::that
- path –
hasRawXpathProperty¶
-
public static ElementProperty
hasRawXpathProperty
(String rawXpathProps, String rawExplanation)¶ Custom property that allows to state the raw expath of a property, and give a string description of it. Example:
Path el = span.that(hasRawXpathProperty("string(.)='x'", "is awesome"), isOnlyChild); assertThat(el.getXPath().get(), equalTo("span[string(.)='x'][count(preceding-sibling::)=0" + "and count(following-sibling::)=0]")); assertThat(el.toString(), is(equalTo("span, that is awesome, and is only child")));
Parameters: - rawXpathProps –
- the xpath property condition string. Will be wrapped with [] in the xpath
- rawExplanation –
- a textual readable description of this property
Returns: a element property that can be applied with Path::that
- rawXpathProps –
hasRef¶
-
public static ElementProperty
hasRef
(String ref)¶ Element with a “ref” attribute equal to the given role.
Parameters: - ref – the value of the role property
Returns: a element property that can be applied with Path::that
hasRole¶
-
public static ElementProperty
hasRole
(String role)¶ Element with a “role” attribute equal to the given role.
Parameters: - role – the value of the role property
Returns: a element property that can be applied with Path::that
hasSource¶
-
public static ElementProperty
hasSource
(String src)¶ Element with a “src” attribute equal to the given parameter. Useful for images.
Parameters: - src – the URI of the image
Returns: a element property that can be applied with Path::that
hasText¶
-
public static ElementProperty
hasText
(String txt)¶ Element has text equals to the given string parameter, ignoring case.
Parameters: - txt –
- the text to match to
Returns: a element property that can be applied with Path::that
- txt –
hasTextContaining¶
-
public static ElementProperty
hasTextContaining
(String txt)¶ The text in the element contains the given parameter, ignoring case
Parameters: - txt –
- the substring to match to
Returns: An element property that can be applied with Path::that
- txt –
hasTextEndingWith¶
-
public static ElementProperty
hasTextEndingWith
(String txt)¶ Element has text that ends with the given parameter
Parameters: - txt –
- the text to match to
Returns: a element property that can be applied with Path::that
- txt –
hasTextStartingWith¶
-
public static ElementProperty
hasTextStartingWith
(String txt)¶ Element has text that starts with the given parameter
Parameters: - txt –
- the text to match to
Returns: a element property that can be applied with Path::that
- txt –
isAfter¶
-
public static ElementProperty
isAfter
(Path... paths)¶ Element appears after all the given parameters in the document
Parameters: - paths –
- elements that precede the current element
Returns: An element property that can be applied with Path::that
- paths –
isAfter¶
-
public static ElementProperty
isAfter
(NPath nPath)¶ Element is after at-least/at-most/exactly the given number of the given element. Example use: import static com.github.loyada.jdollarx.atLeast; input.that(isAfter(atLeast(2).occurrencesOf(div)));
Parameters: - nPath –
- at-least/at-most/exactly the given number of the given element
Returns: An element property that can be applied with Path::that
- nPath –
isAfterSibling¶
-
public static ElementProperty
isAfterSibling
(Path... paths)¶ Element is a sibling of all the elements defined by the given paths, AND is after all those siblings
Parameters: - paths – a list of paths referring to elements
Returns: An element property that can be applied with Path::that
isAfterSibling¶
-
public static ElementProperty
isAfterSibling
(NPath nPath)¶ Element is a sibling of the at-least/at-most/exactly n elements given, and appears after them. Example:
Path el = element.that(isAfterSibling(exactly(2).occurrencesOf(div))); assertThat(el.toString(), is(equalTo("any element, that is after 2 siblings of type: div")));
Parameters: - nPath – a count of elements that are siblings appearing before current elements.
Returns: An element property that can be applied with Path::that
isAncestorOf¶
-
public static ElementProperty
isAncestorOf
(Path... paths)¶ The given elements in the parameters list are contained in the current element
Parameters: - paths –
- a list of elements that are descendants of the current element
Returns: An element property that can be applied with Path::that
- paths –
isBefore¶
-
public static ElementProperty
isBefore
(Path... paths)¶ Element is before all the elements given in the parameters
Parameters: - paths –
- all the elements that appear after the current element
Returns: An element property that can be applied with Path::that
- paths –
isBefore¶
-
public static ElementProperty
isBefore
(NPath nPath)¶ Element is before at-least/at-most/exactly the given number of the given element. Example use:
import static com.github.loyada.jdollarx.isBefore; input.that(isBefore(atLeast(2).occurrencesOf(div)));
Parameters: - nPath –
- at-least/at-most/exactly the given number of the given element
Returns: An element property that can be applied with Path::that
- nPath –
isBeforeSibling¶
-
public static ElementProperty
isBeforeSibling
(Path... paths)¶ Element is a sibling of all the elements defined by the given paths, AND is before all those siblings
Parameters: - paths – a list of paths referring to elements
Returns: An element property that can be applied with Path::that
isBeforeSibling¶
-
public static ElementProperty
isBeforeSibling
(NPath nPath)¶ Element is a sibling of the at-least/at-most/exactly n elements given, and appears before them. Example:
Path el = element.that(isBeforeSibling(exactly(2).occurrencesOf(div))); assertThat(el.toString(), is(equalTo("any element, that is before 2 siblings of type: div")));
Parameters: - nPath – a count of elements that are siblings appearing after current elements.
Returns: An element property that can be applied with Path::that
isChildOf¶
-
public static ElementProperty
isChildOf
(Path path)¶ Element is direct child of the element matched by the given parameter
Parameters: - path –
- the parent of the current element
Returns: An element property that can be applied with Path::that
- path –
isContainedIn¶
-
public static ElementProperty
isContainedIn
(Path path)¶
isDescendantOf¶
-
public static ElementProperty
isDescendantOf
(Path path)¶ Element is inside the given parameter
Parameters: - path – the ancestor of the current element
Returns: An element property that can be applied with Path::that
isInside¶
-
public static ElementProperty
isInside
(Path path)¶ Element is inside the given parameter
Parameters: - path – the ancestor of the current element
Returns: An element property that can be applied with Path::that
isNthFromLastSibling¶
-
public static ElementProperty
isNthFromLastSibling
(Integer reverseIndex)¶ The element is the nth-from-last sibling. Example usage: find the element before the last one in a list.
Parameters: - reverseIndex –
- the place from last, starting at 0 for the last sibling.
Returns: a element property that can be applied with Path::that
- reverseIndex –
isNthSibling¶
-
public static ElementProperty
isNthSibling
(Integer index)¶ The element is the nth sibling. Example usage: find the 4th element in a list.
Parameters: - index –
- starting at 0 for the first one
Returns: a element property that can be applied with Path::that
- index –
isParentOf¶
-
public static ElementProperty
isParentOf
(Path... paths)¶ Element is the parent of the given list of elements
Parameters: - paths –
- a list of elements that are children of the current element
Returns: An element property that can be applied with Path::that
- paths –
isSiblingOf¶
-
public static ElementProperty
isSiblingOf
(Path... paths)¶ Element is a sibling of all the elements defined by the given paths
Parameters: - paths – a list of paths referring to elements
Returns: An element property that can be applied with Path::that
isWithIndex¶
-
public static ElementProperty
isWithIndex
(Integer index)¶ Element that is the nth sibling of its parent
Parameters: - index –
- the index of the element among its sibling, starting with 0
Returns: An element property that can be applied with Path::that
- index –
not¶
-
public static ElementProperty
not
(ElementProperty prop)¶ Element does NOT have the given property.
Parameters: - prop –
- the property which the element must not have
Returns: An element property that can be applied with Path::that
- prop –
withIndexInRange¶
-
public static ElementProperty
withIndexInRange
(int first, int last)¶ The index among its siblings is between first and last parameters. For example: taking a row from a table, which we know is between row number 2 and 4.
Parameters: - first –
- lower index (inclusive, starting at 0)
- last –
- upper index (inclusive, starting at 0)
Returns: a element property that can be applied with Path::that
- first –