Class By
Use the static methods in this class to create arbitrary complex CSS selectors:
// #main [data-list-item=foo] a[href^="https://"] > .fas.fa-check, .external[hidden]
By.group(
By.id("main")
.desc(By.data("listItem", "foo")
.desc(By.element("a").and(By.attribute("href", STARTS_WITH, "https://"))
.child(By.classnames("fas", "fa-check")))),
By.classname("external").and(By.attribute("hidden")));
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Operator used for attribute selectors. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal By
adjacentSibling
(By selector) Combines this selector with the given selector using the+
(adjacent sibling combinator) combinator.final By
Combines this selector with the given selector.static By
Selects all elements that have an attribute name ofname
.static By
Selects all elements that have an attribute name ofname
whose value is exactlyvalue
.static By
attribute
(String name, By.AttributeOperator operator, String value) Selects all elements that have an attribute name ofname
whose value applies to the given operator.final By
Combines this selector with the given selector using the>
(child) combinator.static By
Selects all elements that have the given class attribute.static By
classnames
(String[] classnames) Selects all elements that have all class attributes.static By
classnames
(String first, String second, String... remaining) Selects all elements that have all class attributes.static By
Selects all elements that have an attribute name of data-name
.static By
Selects all elements that have an attribute name of data-name
whose value is exactlyvalue
.static By
data
(String name, By.AttributeOperator operator, String value) Selects all elements that have an attribute name of data-name
whose value applies to the given operator.final By
Combines this selector with the given selector using the (space) combinator.static By
Selects all elements that have the given node name.static By
Selects all elements that have the given node name.static <E extends HTMLElement>
BySelects all elements that have the given node name.boolean
static By
Groups the specified selectors using,
.static By
Groups the specified selectors using,
.int
hashCode()
static By
Selects an element based on the value of its id attribute.static By
Returns a selector as-is.final By
Combines this selector with the given selector using the~
(general sibling) combinator.toString()
-
Constructor Details
-
By
public By()
-
-
Method Details
-
selector
Returns a selector as-is. -
id
Selects an element based on the value of its id attribute. -
element
Selects all elements that have the given node name. -
element
Selects all elements that have the given node name. -
element
Selects all elements that have the given node name. -
classname
Selects all elements that have the given class attribute. -
classnames
Selects all elements that have all class attributes. -
classnames
Selects all elements that have all class attributes. -
attribute
Selects all elements that have an attribute name ofname
. -
attribute
Selects all elements that have an attribute name ofname
whose value is exactlyvalue
.You don't need to enclose the value in single or double quotes. If necessary, quotes are added automatically.
- See Also:
-
attribute
Selects all elements that have an attribute name ofname
whose value applies to the given operator.You don't need to enclose the value in single or double quotes. If necessary, quotes are added automatically.
- See Also:
-
data
Selects all elements that have an attribute name of data-name
.If
name
contains "-" it is used as if, otherwise it is expected to be in camelCase and is converted to kebab-case. -
data
Selects all elements that have an attribute name of data-name
whose value is exactlyvalue
.If
name
contains "-" it is used as if, otherwise it is expected to be in camelCase and is converted to kebab-case.You don't need to enclose the value in single or double quotes. If necessary, quotes are added automatically.
- See Also:
-
data
Selects all elements that have an attribute name of data-name
whose value applies to the given operator.If
name
contains "-" it is used as if, otherwise it is expected to be in camelCase and is converted to kebab-case.You don't need to enclose the value in single or double quotes. If necessary, quotes are added automatically.
- See Also:
-
group
Groups the specified selectors using,
.// #main [data-list-item=foo] a[href^="https://"] > .fas.fa-check, .external[hidden] By.group( By.id("main") .desc(By.data("listItem", "foo") .desc(By.element("a").and(By.attribute("href", STARTS_WITH, "https://")) .child(By.classnames("fas", "fa-check")))), By.classname("external").and(By.attribute("hidden")));
-
group
Groups the specified selectors using,
.// #main [data-list-item=foo] a[href^="https://"] > .fas.fa-check, .external[hidden] By.group( By.id("main") .desc(By.data("listItem", "foo") .desc(By.element("a").and(By.attribute("href", STARTS_WITH, "https://")) .child(By.classnames("fas", "fa-check")))), By.classname("external").and(By.attribute("hidden")));
-
and
Combines this selector with the given selector. Use this method to express selectors likebutton.primary
orinput[type=checkbox]
:// button.primary By.element("button").and(By.classname("primary")); // input[type=checkbox] By.element("input").and(By.attribute("type", "checkbox"));
-
child
Combines this selector with the given selector using the>
(child) combinator. Selects nodes that are direct children of this element. -
desc
Combines this selector with the given selector using the (space) combinator. Selects nodes that are descendants of this element. -
sibling
Combines this selector with the given selector using the~
(general sibling) combinator. This means thatselector
follows this element (though not necessarily immediately), and both share the same parent. -
adjacentSibling
Combines this selector with the given selector using the+
(adjacent sibling combinator) combinator. This means thatselector
directly follows this element, and both share the same parent. -
hashCode
public int hashCode() -
equals
-
toString
-