XPath Practice: Mastering XPath Expressions for Effective Web Automation using Contains() Function.

Test Your Skills with this Fun and Interactive Game


Home->Practice 7

Next
HTML Source document
         <h1 id="h1" name="header1">Heading 1 </h1>
         <h2 id="h2" name="header2">Heading 2 </h2>
         <h3 id="h3" name="header3">Heading 3 </h3>
         <h4 id="h4" name="header4">Heading 4 </h4>
        
         <a href="https://thetestdata.com">Visit Thetestdata </a> 
         
<label class="form-label" id="userEmail-label" name="Email">Email</label>

<p class="form-para" id="userEmail-para" name="Email">Name</p>
                
     <p style="color:red;">This is a red paragraph.</p> 
        
XPath Exercise 7

Q1. Find header1 with Contains()

Q2. Find header2 with Contains()

Q3. Find header3 with Contains()

Q4. Find header4 with Contains()

Q5. Find Email with Contains()

Q6. Find Name with Contains()

Q7. Find hyperlink with Contains()

Q8. Find Red Paragraph with Contains()

XPath O/P

Enter XPath Input here:   

XPath Tips and Syntax For This Page Exercise :

Using contains()

//HTMLtag[contains(@attribute_name,'attribute_value')]

or

//*[contains(@attribute_name,'attribute_value')]

e.g
//h1[contains(@id,'Email')]

The contains() function in XPath can be used to test if a string contains a specified substring.

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.