Class By
java.lang.Object
org.jboss.elemento.By
Typesafe CSS selector API.
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
Nested ClassesModifier and TypeClassDescriptionstatic enumOperator used for attribute selectors. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ByadjacentSibling(By selector) Combines this selector with the given selector using the+(adjacent sibling combinator) combinator.final ByCombines this selector with the given selector.static BySelects all elements that have an attribute name ofname.static BySelects all elements that have an attribute name ofnamewhose value is exactlyvalue.static Byattribute(String name, By.AttributeOperator operator, String value) Selects all elements that have an attribute name ofnamewhose value applies to the given operator.final ByCombines this selector with the given selector using the>(child) combinator.static BySelects all elements that have the given class attribute.static Byclassnames(String[] classnames) Selects all elements that have all class attributes.static Byclassnames(String first, String second, String... remaining) Selects all elements that have all class attributes.static BySelects all elements that have an attribute name of data-name.static BySelects all elements that have an attribute name of data-namewhose value is exactlyvalue.static Bydata(String name, By.AttributeOperator operator, String value) Selects all elements that have an attribute name of data-namewhose value applies to the given operator.final ByCombines this selector with the given selector using the (space) combinator.static BySelects all elements that have the given node name.static BySelects all elements that have the given node name.static <E extends HTMLElement>
BySelects all elements that have the given node name.booleanstatic ByGroups the specified selectors using,.static ByGroups the specified selectors using,.inthashCode()static BySelects an element based on the value of its id attribute.abstract Stringselector()static ByReturns a selector as-is.final ByCombines this selector with the given selector using the~(general sibling) combinator.toString()
-
Constructor Details
-
By
public By()
-
-
Method Details
-
selector
-
id
-
element
-
element
-
element
Selects all elements that have the given node name. -
classname
-
classnames
-
classnames
-
attribute
-
attribute
-
attribute
Selects all elements that have an attribute name ofnamewhose 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
-
data
Selects all elements that have an attribute name of data-namewhose value is exactlyvalue.If
namecontains "-" 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-namewhose value applies to the given operator.If
namecontains "-" 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.primaryorinput[type=checkbox]:// button.primary By.element("button").and(By.classname("primary")); // input[type=checkbox] By.element("input").and(By.attribute("type", "checkbox")); -
child
-
desc
-
sibling
-
adjacentSibling
-
selector
-
hashCode
-
equals
-
toString
-