349. Easy and Regular way of finding XPath Statements for Elements

Though we have practiced many ways of writing XPath statements to locate the elements, its not always required to write the XPath statements. In most of the cases we take the help of 'Firepath' tab under 'FireBug' option.

We are going to use our knowledge of writing the XPath statements without the help of 'Firepath', if and only if the 'XPath' statement returned by the 'Firepath' is:

  • Not Working  (We are going to manually write the XPath statement in this case)
  • Not optimized (We are going to edit the XPath statement returned by the 'Firepath')

Most Regular way of Finding the XPath for Elements:

1. Launch Firefox and navigate to any site say

2. Click on the FireBug icon on the top right side of the page as shown below:

3. Ensure that FireBug interface along with 'FirePath' tab  is displayed on the bottom of the page as shown below:

4. Click on the 'Inspect Element' FireBug option and select any UI element say 'Google Logo' as shown below:

5. Click on the 'Firepath' tab to find out the XPath  property value of the inspected element (i.e. Google Logo in this example) as shown below:

6. Ensure that 'XPath' property value of the selected UI element (i.e. Google Logo) is displayed by default as shown below:

So this is the most regular way of finding the XPath statements in Selenium Automation.

Please comment below to feedback or ask questions.

Typing the Text into Text box by Locating the Text Box field using XPath Statement
will be explained in the next post.

No comments: