Xpath – How to locate WebElements using Xpath ?

What is Xpath and how is it used to identify web elements ?

When we want to use Xpath to locate a web element based , we need to follow certain pre-defined rules.

First of all, let us understand what is Xpath ?

Xpath can be expanded as XML Path . XML stands for Extensible Markup Language .
XML is a language which is is used to store, organise and transport arbitrary data.
It stores data in a key-value pair similar to HTML tags. Therefore xpath can be used to locate HTML elements.

How to create Xpath ?
You can download an add-ons called “Firebug” and “Firepath”  for Mozilla Firefox browser 

Steps to perform in order to locate the web element using Xpath :

1. Load the URL in the browser.
2. Click on the “Firepath” tab
3. Click on the “Arrow” icon on the extreme left
4. Now click on the element on the web page, whose Xpath you want to check
5. It will show the Xpath of the web element in the text box below “firepath” tab

Sometimes this automatically generated Xpath is not able to identify the web element correctly.
Then we need to make changes to this xpath to fit out need.

In the next post we will see , how we can tweak this automatically generated Xpath , to full fill our requirement.

Previous                                                                 Next                                

Links to useful posts: