Locators
- CSS Selectors
 - attribute -- tagName[attribute='value']
 - className -- tagName.className
 - Id -- tagName#Id
 - parent to child traverse -- parentTagName childTagName
 - nth child -- tagName[attribute='value']:nth-child(index)
 - Regex Eg -- "input[type*='pass']"
 - Notes -
 - child to parent traverse is not possible in CSS
 - tagName.className --> here tagName is optional, we can write .className also but the className should be unique.
 - class="submit signInBtn" --> here are 2 identifiers, we can choose any one of them.
 - XPath
 - attribute -- //tagName[@attribute='value']
 - parent to child traverse -- //parentTagName/childTagName
 - index -- //tagName[@attribute='value'][index]
 - Regex Eg -- //button[contains(@class,'submit')]
 - parent to child to child traverse Eg -- //header/div/button[1]/following-sibling::button[1]
 - parent to child to parent to grandParent to child traverse Eg -- //header/div/button[1]/parent::div/parent::header/a
 - Notes -
 - customized Xpath - both the words in the class name must be used. Eg: //button[@class='submit signInBtn']
 - ID, name, className
 - just the ID/name/className respectively.
 - With text
 - linktext
 - normalized-space()='xyz'
 - xpath Eg- //button[text()='Log Out']
 

No comments:
Post a Comment