Class Selectors
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.openqa.selenium.BySynonym for #byAttributestatic org.openqa.selenium.ByFind element with given "alt" attributestatic org.openqa.selenium.BybyAltText(String title, TextMatchOptions options) Find element with given "alt" attributestatic org.openqa.selenium.BybyAttribute(String attributeName, String attributeValue) Find elements having attribute with given value.static org.openqa.selenium.BybyAttribute(String attributeName, String attributeValue, TextMatchOptions options) static org.openqa.selenium.BybyClassName(String className) static org.openqa.selenium.BybyCssSelector(String css) static org.openqa.selenium.Bystatic org.openqa.selenium.Bystatic org.openqa.selenium.BybyLabel(String elementText, TextMatchOptions options) static org.openqa.selenium.BybyLinkText(String linkText) static org.openqa.selenium.Bystatic org.openqa.selenium.BybyPartialLinkText(String partialLinkText) static org.openqa.selenium.BybyPlaceholder(String placeholderText) Find element by "placeholder" attributestatic org.openqa.selenium.BybyPlaceholder(String placeholderText, TextMatchOptions options) Find element by "placeholder" attributestatic org.openqa.selenium.BybyTagAndText(String tag, String elementText) Find element that has given text (the whole text, not a substring).static org.openqa.selenium.Bystatic org.openqa.selenium.ByFind element with given "data-test-id" attribute Name of "data-test-id" attribute can be customized: via system property:-Dselenide.test-id.attribute=data-testid, or in file "selenide.properties":selenide.test-id.attribute=data-testidstatic org.openqa.selenium.ByFind element that has given text (the whole text, not a substring).static org.openqa.selenium.BybyTextCaseInsensitive(String elementText) Same asbyText(String), but case-insensitive.static org.openqa.selenium.ByFind element with given title ("title" attribute)static org.openqa.selenium.BybyTitle(String title, TextMatchOptions options) Find element with given title ("title" attribute)static org.openqa.selenium.ByFind input element with given value ("value" attribute)static org.openqa.selenium.Bystatic org.openqa.selenium.Bystatic org.openqa.selenium.ByshadowDeepCss(String target) static org.openqa.selenium.BywithTagAndText(String tag, String elementText) Find element CONTAINING given text (as a substring).static org.openqa.selenium.ByFind element CONTAINING given text (as a substring).static org.openqa.selenium.BywithTextCaseInsensitive(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.- Since:
- 5.22.0
-
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.- Since:
- 5.22.0
-
byLabel
-
byLabel
-
byPlaceholder
Find element by "placeholder" attribute- Parameters:
placeholderText- the expected placeholder value to find by- Since:
- 7.12.0
-
byPlaceholder
public static org.openqa.selenium.By byPlaceholder(String placeholderText, TextMatchOptions options) Find element by "placeholder" attribute- Parameters:
placeholderText- the expected placeholder value to find byoptions- either case-sensitive or insensitive, either full text or substring etc.- Since:
- 7.12.0
-
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
-
byAttribute
public static org.openqa.selenium.By byAttribute(String attributeName, String attributeValue, TextMatchOptions options) - Since:
- 7.12.0
-
shadowCss
- Since:
- 5.10
- See Also:
-
shadowDeepCss
- Since:
- v6.8.0
- See Also:
-
by
Synonym for #byAttribute -
byTitle
Find element with given title ("title" attribute) -
byTitle
Find element with given title ("title" attribute)- Since:
- 7.12.0
-
byAltText
Find element with given "alt" attribute- Since:
- 7.12.0
-
byAltText
Find element with given "alt" attribute- Since:
- 7.12.0
-
byTestId
Find element with given "data-test-id" attribute Name of "data-test-id" attribute can be customized:- via system property:
-Dselenide.test-id.attribute=data-testid, or - in file "selenide.properties":
selenide.test-id.attribute=data-testid
- Since:
- 7.12.0
- via system property:
-
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)
-