XPath Practice: Mastering XPath Expressions for Effective Web Automation

Test Your Skills with this Fun and Interactive Game

Home->Practice 1


HTML Source document

        <p>Paragraph one</p>
       <h1>Heading 1 </h1>

XPath Exercise 1

Q1. Find Paragraph one

Q2. Find Heading 1

Q3. Find Heading 1 From DIV Tag

Q4. Find Paragraph From DIV Tag

XPath O/P

Enter XPath Input here:   

Tips and Syntax For This Page Xpath Exercise :

Using Double Slash

Syntax : //tagname

Where tagname is the name of the HTML element you want to search for.

Here are a few examples to demonstrate how to use the double slash in XPath:

e.g :
1) //p
2) //form/div[1]/div/div[1]/div/div/input[1]

The double slash (//) in an XPath expression is used to search for elements anywhere in the document, regardless of their location in the hierarchy of elements. For example, the expression //input would select all input elements in the document, regardless of whether they are direct children of the root element or are nested several levels deep inside other elements.

We would love to hear your thoughts, suggestions, concerns or problems with anything so we can improve. Request you to please use Social Media button in Right Side for this website growth.