Class Selectors
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.openqa.selenium.By
Synonym for #byAttributestatic org.openqa.selenium.By
byAttribute
(String attributeName, String attributeValue) Find elements having attribute with given value.static org.openqa.selenium.By
byClassName
(String className) static org.openqa.selenium.By
byCssSelector
(String css) static org.openqa.selenium.By
static org.openqa.selenium.By
byLinkText
(String linkText) static org.openqa.selenium.By
static org.openqa.selenium.By
byPartialLinkText
(String partialLinkText) static org.openqa.selenium.By
byTagAndText
(String tag, String elementText) Find element that has given text (the whole text, not a substring).static org.openqa.selenium.By
static org.openqa.selenium.By
Find element that has given text (the whole text, not a substring).static org.openqa.selenium.By
byTextCaseInsensitive
(String elementText) Same asbyText(String)
, but case-insensitive.static org.openqa.selenium.By
Find element with given title ("title" attribute)static org.openqa.selenium.By
Find input element with given value ("value" attribute)static org.openqa.selenium.By
static org.openqa.selenium.By
static org.openqa.selenium.By
shadowDeepCss
(String target) static org.openqa.selenium.By
withTagAndText
(String tag, String elementText) Find element CONTAINING given text (as a substring).static org.openqa.selenium.By
Find element CONTAINING given text (as a substring).static org.openqa.selenium.By
withTextCaseInsensitive
(String elementText) Same aswithText(String)
, but case-insensitive.
-
Constructor Details
-
Selectors
public Selectors()
-
-
Method Details
-
withText
Find element CONTAINING given text (as a substring).This method ignores difference between space, \n, \r, \t and This method ignores multiple spaces.
- Parameters:
elementText
- Text to search inside element- Returns:
- standard selenium By criteria`
-
withTagAndText
Find element CONTAINING given text (as a substring).This method ignores difference between space, \n, \r, \t and This method ignores multiple spaces.
- Parameters:
tag
- Html tag name (e.g. "dev", "span", "li", "a", "td")elementText
- Text to search inside element- Returns:
- standard selenium By criteria`
-
withTextCaseInsensitive
Same aswithText(String)
, but case-insensitive. -
byText
Find element that has given text (the whole text, not a substring).This method ignores difference between space, \n, \r, \t and This method ignores multiple spaces. This method is case-sensitive.
- Parameters:
elementText
- Text that searched element should have- Returns:
- standard selenium By criteria
-
byTagAndText
Find element that has given text (the whole text, not a substring).This method ignores difference between space, \n, \r, \t and This method ignores multiple spaces. This method is case-sensitive.
- Parameters:
tag
- Html tag name (e.g. "dev", "span", "li", "a", "td")elementText
- Text that searched element should have- Returns:
- standard selenium By criteria
-
byTextCaseInsensitive
Same asbyText(String)
, but case-insensitive. -
byAttribute
Find elements having attribute with given value.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>
- Parameters:
attributeName
- name of attribute, should not be empty or nullattributeValue
- value of attribute, should not contain both apostrophes and quotes- Returns:
- standard selenium By cssSelector criteria
-
shadowCss
-
shadowDeepCss
-
by
Synonym for #byAttribute -
byTitle
Find element with given title ("title" attribute) -
byValue
Find input element with given value ("value" attribute) -
byName
- See Also:
-
By.name(java.lang.String)
-
byXpath
- See Also:
-
By.xpath(java.lang.String)
-
byLinkText
- See Also:
-
By.linkText(java.lang.String)
-
byPartialLinkText
- See Also:
-
By.partialLinkText(java.lang.String)
-
byId
- See Also:
-
By.id(java.lang.String)
-
byCssSelector
- See Also:
-
By.cssSelector(java.lang.String)
-
byClassName
- See Also:
-
By.className(java.lang.String)
-
byTagName
- See Also:
-
By.tagName(java.lang.String)
-