public final class ElementProperties extends Object
Path instances, that are used with the methods Path.that(com.github.loyada.jdollarx.ElementProperty...)
and Path.and(com.github.loyada.jdollarx.ElementProperty...).| Modifier and Type | Field and Description |
|---|---|
static ElementProperty |
hasChildren
The element has 1 or more children (the opposite from hasNoChildren).
|
static ElementProperty |
hasNoChildren
The element has no children.
|
static ElementProperty |
hasSomeText
Element has non-empty text
|
static ElementProperty |
isChecked
The element is checked
|
static ElementProperty |
isDisabled
The element is diabled
|
static ElementProperty |
isEnabled
The element is enabled
|
static ElementProperty |
isHidden
Element that is hidden.
|
static ElementProperty |
isLastSibling
The element is the last sibling (ie: last child) of its parent.
|
static ElementProperty |
isOnlyChild
The element is the only direct child of its parent.
|
static ElementProperty |
isSelected
The element is selected
|
| Modifier and Type | Method and Description |
|---|---|
static ElementProperty |
contains(Path... paths)
The given elements in the parameters list are contained in the current element
|
static ElementProperty |
hasAggregatedCaseSensitiveTextContaining(String txt)
When aggregating all the text under this element, it contains the given substring.
|
static ElementProperty |
hasAggregatedCaseSensitiveTextEqualTo(String txt)
When aggregating all the text under this element, it equals to the given parameter.
|
static ElementProperty |
hasAggregatedTextContaining(String txt)
When aggregating all the text under this element, it contains the given substring (ignoring case)
|
static ElementProperty |
hasAggregatedTextEndingWith(String txt)
When aggregating all the text under this element, it ends with the given substring (ignoring case)
|
static ElementProperty |
hasAggregatedTextEqualTo(String txt)
When aggregating all the text under this element, it equals to the given parameter.
|
static ElementProperty |
hasAggregatedTextStartingWith(String txt)
When aggregating all the text under this element, it starts with the given substring (ignoring case)
|
static ElementProperty |
hasAncesctor(Path path)
Element is inside the given parameter
|
static ElementProperty |
hasAnyOfClasses(String... cssClasses)
Element that has at least one of the classes given
|
static ElementProperty |
hasAttribute(String attribute,
String value) |
static ElementProperty |
hasCaseSensitiveText(String txt)
Element has text equals to the given string parameter.
|
static ElementProperty |
hasCaseSensitiveTextContaining(String txt)
The text in the element contains the given parameter.
|
static ElementProperty |
hasChild(Path... paths)
Element is the parent of the given list of elements
|
static ElementProperty |
hasClass(String className)
Has the class given in the parameter
|
static ElementProperty |
hasClassContaining(String classSubString)
Element that has a class with name that contain the given parameter
|
static ElementProperty |
hasClasses(String... cssClasses)
Element that has all of the given classes
|
static ElementProperty |
hasDescendant(Path... paths)
The given elements in the parameters list are contained in the current element
|
static ElementProperty |
hasId(String id)
Element has ID equals to the given parameter
|
static ElementProperty |
hasName(String name)
Element with a "name" attribute equal to the given parameter.
|
static ElementPropertyWithNumericalBoundaries |
hasNChildren(Integer n)
The element has n direct children
|
static ElementProperty |
hasNonOfTheClasses(String... cssClasses)
Element that has none of the given classes
|
static ElementProperty |
hasParent(Path path)
Element is direct child of the element matched by the given parameter
|
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.
|
static ElementProperty |
hasRole(String role)
Element with a "role" attribute equal to the given role.
|
static ElementProperty |
hasSource(String src)
Element with a "src" attribute equal to the given parameter.
|
static ElementProperty |
hasText(String txt)
Element has text equals to the given string parameter, ignoring case.
|
static ElementProperty |
hasTextContaining(String txt)
The text in the element contains the given parameter, ignoring case
|
static ElementProperty |
hasTextEndingWith(String txt)
Element has text that ends with the given parameter
|
static ElementProperty |
hasTextStartingWith(String txt)
Element has text that starts with the given parameter
|
static ElementProperty |
isAfter(NPath nPath)
Element is after at-least/at-most/exactly the given number of the given element.
|
static ElementProperty |
isAfter(Path... paths)
Element appears after all the given parameters in the document
|
static ElementProperty |
isAfterSibling(NPath nPath)
Element is a sibling of the at-least/at-most/exactly n elements given, and appears after them.
|
static ElementProperty |
isAfterSibling(Path... paths)
Element is a sibling of all the elements defined by the given paths, AND is after all those siblings
|
static ElementProperty |
isAncestorOf(Path... paths)
The given elements in the parameters list are contained in the current element
|
static ElementProperty |
isBefore(NPath nPath)
Element is before at-least/at-most/exactly the given number of the given element.
|
static ElementProperty |
isBefore(Path... paths)
Element is before all the elements given in the parameters
|
static ElementProperty |
isBeforeSibling(NPath nPath)
Element is a sibling of the at-least/at-most/exactly n elements given, and appears before them.
|
static ElementProperty |
isBeforeSibling(Path... paths)
Element is a sibling of all the elements defined by the given paths, AND is before all those siblings
|
static ElementProperty |
isChildOf(Path path)
Element is direct child of the element matched by the given parameter
|
static ElementProperty |
isContainedIn(Path path) |
static ElementProperty |
isDescendantOf(Path path)
Element is inside the given parameter
|
static ElementProperty |
isInside(Path path)
Element is inside the given parameter
|
static ElementProperty |
isNthFromLastSibling(Integer reverseIndex)
The element is the nth-from-last sibling.
|
static ElementProperty |
isNthSibling(Integer index)
The element is the nth sibling.
|
static ElementProperty |
isParentOf(Path... paths)
Element is the parent of the given list of elements
|
static ElementProperty |
isSiblingOf(Path... paths)
Element is a sibling of all the elements defined by the given paths
|
static ElementProperty |
isWithIndex(Integer index)
Element that is the nth sibling of its parent
|
static ElementProperty |
not(ElementProperty prop)
Element does NOT have the given property.
|
static ElementProperty |
withIndexInRange(int first,
int last)
The index among its siblings is between first and last parameters.
|
public static final ElementProperty isLastSibling
public static final ElementProperty isDisabled
public static final ElementProperty isEnabled
public static final ElementProperty isChecked
public static final ElementProperty isSelected
public static final ElementProperty hasNoChildren
public static final ElementProperty hasChildren
public static final ElementProperty isOnlyChild
public static ElementProperty isHidden
public static ElementProperty hasSomeText
public static ElementPropertyWithNumericalBoundaries hasNChildren(Integer n)
n - the number of childrenpublic static ElementProperty isNthFromLastSibling(Integer reverseIndex)
reverseIndex - - the place from last, starting at 0 for the last sibling.public static ElementProperty isNthSibling(Integer index)
index - - starting at 0 for the first onepublic static ElementProperty withIndexInRange(int first, int last)
first - - lower index (inclusive, starting at 0)last - - upper index (inclusive, starting at 0)public static ElementProperty hasRawXpathProperty(String rawXpathProps, String rawExplanation)
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")));
rawXpathProps - - the xpath property condition string. Will be wrapped with [] in the xpathrawExplanation - - a textual readable description of this propertypublic static ElementProperty hasText(String txt)
txt - - the text to match topublic static ElementProperty hasCaseSensitiveText(String txt)
txt - - the text to match to (case sensitive)public static ElementProperty hasTextStartingWith(String txt)
txt - - the text to match topublic static ElementProperty hasTextEndingWith(String txt)
txt - - the text to match topublic static ElementProperty hasId(String id)
id - - the ID to match topublic static ElementProperty hasName(String name)
name - the value of the name propertypublic static ElementProperty hasSource(String src)
src - the URI of the imagepublic static ElementProperty hasRole(String role)
role - the value of the role propertypublic static ElementProperty hasAttribute(String attribute, String value)
public static ElementProperty hasAnyOfClasses(String... cssClasses)
cssClasses - - the class names to match topublic static ElementProperty hasClasses(String... cssClasses)
cssClasses - - the class names to match topublic static ElementProperty hasClassContaining(String classSubString)
classSubString - a string that should be contained in the classpublic static ElementProperty hasNonOfTheClasses(String... cssClasses)
cssClasses - - a list of class names, none of which is present in elementpublic static ElementProperty isWithIndex(Integer index)
index - - the index of the element among its sibling, starting with 0public static ElementProperty hasTextContaining(String txt)
txt - - the substring to match topublic static ElementProperty hasCaseSensitiveTextContaining(String txt)
txt - - the substring to match to (case sensitive)public static ElementProperty hasClass(String className)
className - the class the element haspublic static ElementProperty hasAggregatedTextEqualTo(String txt)
txt - the aggregated, case insensitive, text inside the elementpublic static ElementProperty hasAggregatedCaseSensitiveTextEqualTo(String txt)
txt - the aggregated, case insensitive, text inside the elementpublic static ElementProperty hasAggregatedTextStartingWith(String txt)
txt - the prefix of the aggregated, case insensitive, text inside the elementpublic static ElementProperty hasAggregatedTextEndingWith(String txt)
txt - the suffix of the aggregated, case insensitive, text inside the elementpublic static ElementProperty hasAggregatedTextContaining(String txt)
txt - a substring of the aggregated, case insensitive, text inside the elementpublic static ElementProperty hasAggregatedCaseSensitiveTextContaining(String txt)
txt - a substring of the aggregated, case sensitive, text inside the elementpublic static ElementProperty isChildOf(Path path)
path - - the parent of the current elementpublic static ElementProperty hasParent(Path path)
path - - the parent of the current elementpublic static ElementProperty isParentOf(Path... paths)
paths - - a list of elements that are children of the current elementpublic static ElementProperty hasChild(Path... paths)
paths - - a list of elements that are children of the current elementpublic static ElementProperty contains(Path... paths)
paths - - a list of elements that are descendants of the current elementpublic static ElementProperty isAncestorOf(Path... paths)
paths - - a list of elements that are descendants of the current elementpublic static ElementProperty hasDescendant(Path... paths)
paths - - a list of elements that are descendants of the current elementpublic static ElementProperty hasAncesctor(Path path)
path - the ancestor of the current elementpublic static ElementProperty isDescendantOf(Path path)
path - the ancestor of the current elementpublic static ElementProperty isInside(Path path)
path - the ancestor of the current elementpublic static ElementProperty isContainedIn(Path path)
public static ElementProperty isAfter(Path... paths)
paths - - elements that precede the current elementpublic static ElementProperty isAfter(NPath nPath)
nPath - - at-least/at-most/exactly the given number of the given elementpublic static ElementProperty isBefore(Path... paths)
paths - - all the elements that appear after the current elementpublic static ElementProperty isBefore(NPath nPath)
import static com.github.loyada.jdollarx.isBefore;
input.that(isBefore(atLeast(2).occurrencesOf(div)));
nPath - - at-least/at-most/exactly the given number of the given elementpublic static ElementProperty isSiblingOf(Path... paths)
paths - a list of paths referring to elementspublic static ElementProperty isAfterSibling(Path... paths)
paths - a list of paths referring to elementspublic static ElementProperty isAfterSibling(NPath nPath)
Path el = element.that(isAfterSibling(exactly(2).occurrencesOf(div)));
assertThat(el.toString(), is(equalTo("any element, that is after 2 siblings of type: div")));
nPath - a count of elements that are siblings appearing before current elements.public static ElementProperty isBeforeSibling(Path... paths)
paths - a list of paths referring to elementspublic static ElementProperty isBeforeSibling(NPath nPath)
Path el = element.that(isBeforeSibling(exactly(2).occurrencesOf(div)));
assertThat(el.toString(), is(equalTo("any element, that is before 2 siblings of type: div")));
nPath - a count of elements that are siblings appearing after current elements.public static ElementProperty not(ElementProperty prop)
prop - - the property which the element must not haveCopyright © 2019. All rights reserved.