Is there a way to learn xpath without using firebug or xpath as firefox is not supporting the addons?
Solution 1:
Here is the simple approach that will work in all browsers.
Using the console: works in all browsers
You can execute any xpath using "$x" in the browser console as shown below. Here is the general notation $x("xpath goes here")
, this will return the array so if you want to get the first matching element then you have to do something like this $x("xpath goes here")[0]
as shown in the below image.
Using Developer Tools in Chrome:
If you want to use chrome then you can use the developer tools > elements tab for xpath and css validation besides console.
Press 'F12' when you are in chrome to open the developer tools, then select "Eelements" tab. Now press 'Ctrl+F' and enter the xpath in the search box at the bottom, you will see the number of matching elements count at the right end of the search box as shown in the screenshot.
For Beginners:
As suggested by @BillHillerman in a comment below: If you are beginner does not know who to write the xpath then you can relay on the xpath that will be provided by chrome browser. Right click on element that you are interested in then click on Inspect
. Now right click on the html code of the element Copy > Copy Xpath
. Now you have the xpath in the clipboard for you.
Chrome provided xpath: