Selenium Locators

1) id();
2) name();
3) className();
4) cssSelector();
5) linkText();
6) partialLinkText();
7) tagName();
8) xpath();

  • absolute or Full xpath
    1) / start 2) from start tagname
  • relative
    1) // start 2) current node or parent corrent node //[@attributename=’attributevalue’] //[@attributename=”attributevalue”]
    //tagname[@attributename=’attributevalue’]
    //tagname[@attributename=”attributevalue”]
    • Index Method
      ()[10]
    • Parent to current node
      //*[@attributename=’attributevalue’]/tagname
    • text
      //*[text()=’Register’]
    • contains
      //tagname[contains(text(),’Rep’)]
      //*[contains(text(),’Rep’)]
      //tagname[contains(text(),’Repository’)]
    • normalize-space
      //tagname[normalize-space()=’Register’]
    • xpath axis

9) Selenium Relative Locators: 4

  • below();
  • above();
  • near();
  • toLeftOf();
  • toRightOf();

—cssSelector——-
id or class
id:
tagName#idattributevalue
or
#idattributevalue
class:
tagName.classattributevalue
or
.classattributevalue