XPath Practice: Mastering XPath Expressions for Effective Web Automation using And and OR Operator.

Test Your Skills with this Fun and Interactive Game

Home->Practice 6

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>
<label class="form-label" id="userEmail-label" name="Email">

<p class="form-para" id="userEmail-para" name="Email">
XPath Exercise 6

Q1. Find header1 with And Operator

Q2. Find header2 with And Operator

Q3. Find header3 with And Operator

Q4. Find header4 with And Operator

Q5. Find header1 with OR Operator

Q6. Find header2 with OR Operator

Q7. Find header3 with OR Operator

Q8. Find header4 with OR Operator

Q9. Find Email with And Operator

Q10. Find Email with OR Operator

Q11. Find Name with And Operator

Q12. Find Name with OR Operator

XPath O/P

Enter XPath Input here:   

XPath Tips and Syntax For This Page Exercise :

Using AND

//HTMLtag[@attribute_name1='attribute_value1' and @attribute_name2='attribute_value2]

//*[@attribute_name1='attribute_value1' and @attribute_name2='attribute_value2]


//input[@id='Email' and @name='password']

The and operator in XPath is used to combine two or more conditions. The and operator returns true only if all of the conditions it combines are true.

Using OR

//HTMLtag[@attribute_name1='attribute_value1' or @attribute_name2='attribute_value2]


//*[@attribute_name1='attribute_value1' or @attribute_name2='attribute_value2]

//input[@id='Email' or @name='password']
We would love to hear your thoughts, suggestions, concerns or problems with anything so we can improve!