public class Selectors
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Selectors.ByText |
static class |
Selectors.WithText |
| Constructor and Description |
|---|
Selectors() |
| Modifier and Type | Method and Description |
|---|---|
static By |
by(java.lang.String attributeName,
java.lang.String attributeValue)
Synonym for #byAttribute
|
static By |
byAttribute(java.lang.String attributeName,
java.lang.String attributeValue)
Find elements having attribute with given value.
|
static By |
byClassName(java.lang.String className) |
static By |
byCssSelector(java.lang.String css) |
static By |
byId(java.lang.String id) |
static By |
byLinkText(java.lang.String linkText) |
static By |
byName(java.lang.String name) |
static By |
byPartialLinkText(java.lang.String partialLinkText) |
static By |
byTagName(java.lang.String tagName) |
static By |
byText(java.lang.String elementText)
Find element that has given text (the whole text, not a substring).
|
static By |
byTitle(java.lang.String title)
Find element with given title ("title" attribute)
|
static By |
byValue(java.lang.String value)
Find input element with given value ("value" attribute)
|
static By |
byXpath(java.lang.String xpath) |
static By |
shadowCss(java.lang.String target,
java.lang.String shadowHost,
java.lang.String... innerShadowHosts) |
static By |
withText(java.lang.String elementText)
Find element CONTAINING given text (as a substring).
|
public static By withText(java.lang.String elementText)
This method ignores difference between space, \n, \r, \t and This method ignores multiple spaces.
elementText - Text to search inside elementpublic static By byText(java.lang.String elementText)
This method ignores difference between space, \n, \r, \t and This method ignores multiple spaces.
elementText - Text that searched element should havepublic static By byAttribute(java.lang.String attributeName,
java.lang.String attributeValue)
Examples:
<div binding="fieldValue"></div>
Find element with attribute 'binding' EXACTLY containing text 'fieldValue' , use:
byAttribute("binding", "fieldValue")
For finding difficult/generated data attribute which contains some value:
<div binding="userName17fk5n6kc2Ds45F40d0fieldValue_promoLanding word"></div>
Find element with attribute 'binding' CONTAINING text 'fieldValue', use symbol '*' with attribute name: byAttribute("binding*", "fieldValue") it same as By.cssSelector("[binding*='fieldValue']")
Find element whose attribute 'binding' BEGINS with 'userName', use symbol '^' with attribute name: byAttribute("binding^", "fieldValue")
Find element whose attribute 'binding' ENDS with 'promoLanding', use symbol '$' with attribute name: byAttribute("binding$", "promoLanding")
Find element whose attribute 'binding' CONTAINING WORD 'word': byAttribute("binding~", "word")
Seems to work incorrectly if attribute name contains dash, for example: <option data-mailServerId="123"></option>
attributeName - name of attribute, should not be empty or nullattributeValue - value of attribute, should not contain both apostrophes and quotespublic static By shadowCss(java.lang.String target,
java.lang.String shadowHost,
java.lang.String... innerShadowHosts)
ByShadow.cssSelector(java.lang.String, java.lang.String, java.lang.String...)public static By by(java.lang.String attributeName,
java.lang.String attributeValue)
public static By byTitle(java.lang.String title)
public static By byValue(java.lang.String value)
public static By byName(java.lang.String name)
By#name(java.lang.String)public static By byXpath(java.lang.String xpath)
By#xpath(java.lang.String)public static By byLinkText(java.lang.String linkText)
By#linkText(java.lang.String)public static By byPartialLinkText(java.lang.String partialLinkText)
By#partialLinkText(java.lang.String)public static By byId(java.lang.String id)
By#id(java.lang.String)public static By byCssSelector(java.lang.String css)
By#cssSelector(java.lang.String)public static By byClassName(java.lang.String className)
By#className(java.lang.String)public static By byTagName(java.lang.String tagName)
By#tagName(java.lang.String)