XPath Practice: Mastering XPath Expressions for Effective Web Automation
Test Your Skills with this Fun and Interactive Game
HTML Game Code 1
<div>
<p>Paragraph one</p>
<h1>Heading 1 </h1>
</div>
XPath Practice Exercise 1
Q1. Find Paragraph one
Q2. Find Heading 1
Q3. Find Heading 1 From DIV Tag
Q4. Find Paragraph From DIV Tag
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.