Class Selectors


  • public class Selectors
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Selectors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.openqa.selenium.By by​(java.lang.String attributeName, java.lang.String attributeValue)
      Synonym for #byAttribute Seems to work incorrectly in HtmlUnit and PhantomJS if attribute name contains dash (e.g.
      static org.openqa.selenium.By byAttribute​(java.lang.String attributeName, java.lang.String attributeValue)
      Find elements having attribute with given value.
      static org.openqa.selenium.By byClassName​(java.lang.String className)  
      static org.openqa.selenium.By byCssSelector​(java.lang.String css)  
      static org.openqa.selenium.By byId​(java.lang.String id)  
      static org.openqa.selenium.By byLinkText​(java.lang.String linkText)  
      static org.openqa.selenium.By byName​(java.lang.String name)  
      static org.openqa.selenium.By byPartialLinkText​(java.lang.String partialLinkText)  
      static org.openqa.selenium.By byText​(java.lang.String elementText)
      Find element that has given text (the whole text, not a substring).
      static org.openqa.selenium.By byTitle​(java.lang.String title)
      Find element with given title ("title" attribute)
      static org.openqa.selenium.By byValue​(java.lang.String value)
      Find input element with given value ("value" attribute)
      static org.openqa.selenium.By byXpath​(java.lang.String xpath)  
      static org.openqa.selenium.By withText​(java.lang.String elementText)
      Find element CONTAINING given text (as a substring).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Selectors

        public Selectors()
    • Method Detail

      • withText

        public static org.openqa.selenium.By withText​(java.lang.String elementText)
        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`
      • byText

        public static org.openqa.selenium.By byText​(java.lang.String elementText)
        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.
        Parameters:
        elementText - Text that searched element should have
        Returns:
        standard selenium By criteria
      • byAttribute

        public static org.openqa.selenium.By byAttribute​(java.lang.String attributeName,
                                                         java.lang.String attributeValue)
        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 null
        attributeValue - value of attribute, should not contain both apostrophes and quotes
        Returns:
        standard selenium By cssSelector criteria
      • by

        public static org.openqa.selenium.By by​(java.lang.String attributeName,
                                                java.lang.String attributeValue)
        Synonym for #byAttribute Seems to work incorrectly in HtmlUnit and PhantomJS if attribute name contains dash (e.g. "data-mailServerId")
      • byTitle

        public static org.openqa.selenium.By byTitle​(java.lang.String title)
        Find element with given title ("title" attribute)
      • byValue

        public static org.openqa.selenium.By byValue​(java.lang.String value)
        Find input element with given value ("value" attribute)
      • byName

        public static org.openqa.selenium.By byName​(java.lang.String name)
        Since:
        3.1
        See Also:
        By.name(java.lang.String)
      • byXpath

        public static org.openqa.selenium.By byXpath​(java.lang.String xpath)
        Since:
        3.1
        See Also:
        By.xpath(java.lang.String)
      • byLinkText

        public static org.openqa.selenium.By byLinkText​(java.lang.String linkText)
        Since:
        3.1
        See Also:
        By.linkText(java.lang.String)
      • byPartialLinkText

        public static org.openqa.selenium.By byPartialLinkText​(java.lang.String partialLinkText)
        Since:
        3.1
        See Also:
        By.partialLinkText(java.lang.String)
      • byId

        public static org.openqa.selenium.By byId​(java.lang.String id)
        Since:
        3.1
        See Also:
        By.id(java.lang.String)
      • byCssSelector

        public static org.openqa.selenium.By byCssSelector​(java.lang.String css)
        Since:
        3.8
        See Also:
        By.cssSelector(java.lang.String)
      • byClassName

        public static org.openqa.selenium.By byClassName​(java.lang.String className)
        Since:
        3.8
        See Also:
        By.className(java.lang.String)