1) id();
2) name();
3) className();
4) cssSelector(); – id(#) or class(.)
5) linkText();
6) partialLinkText();
7) tagName();
8) xpath();
- absolute or Full xpath
1) / start 2) from start tagname - relative ( In the real time project )
1) // start 2) current node or parent corrent node //[@anyattributename=’thatattributevalue’] //[@attributename=”attributevalue”]
//tagname[@attributename=’attributevalue’]
//tagname[@attributename=”attributevalue”]- Index Method
()[10] - Parent to current node
//*[@idattributename=’attributevalue’]/tagname - text // Complete text
//*[text()=’Register’]
//tagname[text()=”Register”] - contains // partialtext
//tagname[contains(text(),’Rep’)]
//*[contains(text(),’Rep’)]
//tagname[contains(text(),’Repository’)] V V V IMP //tagname[contains(@id,”dynamicpart”)] //img[contains(@src,’fvJauBWDL’)] - normalize-space [Same like text approach]
//tagname[normalize-space()=’Register’]
//*[normalize-space()=’Register’]
//tagname[@attribute1=’value1′ and @attribute2=’value2′]
//tagname[@attribute1=’value1′ or @attribute2=’value2′] - Index Method
//input[@id=’q’]
//*[@id=”q”]
- xpath axis
//a[@class='boards']
9) Selenium Relative Locators: 4
- below();
- above();
- near();
- toLeftOf();
- toRightOf();
—cssSelector——-
id or class
id:
tagname#idattributevalue
or
#idattributevalue
class:
tagName.classattributevalue
or
.classattributevalue