Recall & Review
beginner
What is XPath in Selenium?
XPath is a language used to locate elements on a web page by navigating through the HTML structure.
Click to reveal answer
beginner
How do you select an element with a specific attribute using XPath?
Use the syntax //tagname[@attribute='value'] to select elements with a specific attribute value.
Click to reveal answer
beginner
Example: Write XPath to find an input element with id 'username'.
//input[@id='username'] selects the input element whose id attribute equals 'username'.
Click to reveal answer
beginner
What does the XPath //button[@type='submit'] select?
It selects all
<button> elements where the attribute type has the value submit.Click to reveal answer
beginner
Why is using attributes in XPath locators helpful in Selenium tests?
Attributes help precisely identify elements, making tests more reliable and less likely to break if the page layout changes.
Click to reveal answer
Which XPath expression selects a div element with class 'header'?
✗ Incorrect
The correct syntax uses @ to specify the attribute: //div[@class='header'].
What does the XPath //input[@name='email'] select?
✗ Incorrect
It selects input elements whose name attribute equals 'email'.
How do you select elements with multiple attributes in XPath?
✗ Incorrect
Use 'and' to combine multiple attribute conditions: //tag[@attr1='value1' and @attr2='value2'].
Which is the correct XPath to find a button with attribute disabled?
✗ Incorrect
To select elements with an attribute regardless of value, use //button[@disabled].
What is the purpose of using XPath with attributes in Selenium?
✗ Incorrect
XPath with attributes helps find elements precisely based on their attribute values.
Explain how to write an XPath expression to select an element by its attribute.
Think of the pattern: //tag[@attribute='value']
You got /5 concepts.
Describe why using attributes in XPath locators improves Selenium test reliability.
Consider how attributes help pinpoint elements even if the page structure changes.
You got /4 concepts.