Home->Practice 7 |
Next Exercise >> | |
---|---|---|
Please Follow Step 1: Read XPath Question >> | Step 2: Check HTML Source Code >> | Step3: Enter XPath Syntax in O/P Box |
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()
<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>
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.