Xpath in Selenium
Implementation of Xpath in Selenium
It is to identify the elements with tag names
It is of two types
1)relative x path
2) Absolute x path
1) Relative x path:-
we can identify the elements with the help of parent tag and with unique attributes.
In attributes we can provide multiple also to identify the element.
//input [@id=’f-id’ and @name=’name’]
Interested in mastering Selenium Training? Enroll now for FREE demo on Selenium Training.
2) Absolute xpath:---
By using relative xpath if we are unable identify the element then we can go absolute path
It will identify the element with the complete hierarchal xml path of the element.
we can take the absolute xpath from the tool fire path .It is an add on for firebug.
Launch Firefox and open below url
Go to the above path click on “add to Firefox”
How to capture xpath:-
Right click on the element click on inspect else with firebug and then click on the tagitive element and then click on inspect in fire path
By default it generates relative x path
To got the absolute xpath àclick on arrow mark at fire pathàselect general xpath
Done fire bug and capture the xpath again to get the absolute xpath
Note:-xpath should always starts with “//”(or)”xpath=”
Learn more about Selenium Interview Questions in this blog post.
DOM(document object model):-
This approach is derived from java script
It will identify the elements based on the form name.
For an Indepth knowledge on Selenium, click on below