Finding Xpath in different Ways
1.) //tagname[@attribute='value'] // to go to any class r any value
like id r tag etc.... drictly give //tagname[@class='value']
2.) //tagname[text()='xxx'] // to go to any text directly
give dat in xpath // tagname[text()='gotodattext'
3.) //tagname[contains(text(),'xxx')] // to find
any text is there r not in the linktext if spaces are there we use this
4) //tagname[@att='value']/parent::ul // to go to immediate upper attribute we use this
5.) //tagname[@att='value']/div // to go to immediate lower attribute we use this
6) //tagname[@att='value']/ancestor::div //to go to any of the upper
attribute we use this by giving that attribute
7) //tagname[@att='value']/descendant::div // to go to any lower attribute we use
this by giving that attribute
8) //tagname[@att='value']/following-sibling::li //to go to any
upper attribute which are in the parent class we use this by giving that attribute
9) //tagname[@att='value']/preceding-sibling::li // to go to any lower
attribute which are in the parent class we use this by giving that attribute
//a[contains(text(),'Books')]
//div[@class='footer-menu-wrapper']/div[1]/ul/li[1]
(//div[@class='footer-menu-wrapper']/div)[2]/ul/li[2]
No comments:
Post a Comment