Thursday, January 5, 2017

XPATH tutorial


Some commonly used X paths



*basic syntax of xpath

//tagName[@attributeName='value']

* count of all webelements
//*[count(*)]


//*[contains(@style, 'left: 39px')]

//div/a[text()]

*find all nodes or find any nodes
//*[@div] or //*[@class]

*check all tags which has attributes and value
//*[@attributeName='value']

*for two attributes and
//tageName[@attributeName1='value'][@attributeName1='value']

*for two attributes or
//tageName[@attribute1='value' or @attribute2='value']

*contains example
//tageName[contains(@attributeName,'value')]

*search for text on any tag
//*[text()='value']
*dynamic xpath for specific tagName using contains 
//tagName[contains(@text,'partialValue')]
*dynamic xpath for any tageName using contains
//*[contains(@text,'partialValue')]
//*[contains(@id,'partialValue')]
*use of start-with
//tagName[starts-with(@id,'partialValue')]



//*[contains(@onclick ,'javascript:CallARGRemedySmartReporting')]