Challenge - 5 Problems
XPath Text() Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this XPath query?
Given the HTML snippet below, what will the XPath
//button[text()='Submit'] select?Selenium Python
<button>Submit</button> <button>submit</button> <button> Submit </button>
Attempts:
2 left
💡 Hint
Remember that XPath text() matches exact text content including case and spaces.
✗ Incorrect
The XPath
//button[text()='Submit'] matches only buttons whose text content is exactly 'Submit'. The first button matches exactly. The second has lowercase 'submit' and the third has spaces, so they do not match.❓ assertion
intermediate2:00remaining
Which assertion correctly verifies the presence of a button with text 'Cancel' using XPath?
You want to assert that a button with text 'Cancel' exists on the page using Selenium and XPath. Which assertion is correct?
Selenium Python
from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC wait = WebDriverWait(driver, 10)
Attempts:
2 left
💡 Hint
XPath text() is case-sensitive and matches exact text.
✗ Incorrect
Option B uses the exact text 'Cancel' which matches the button text exactly. Option B is missing a closing bracket and will cause a syntax error. Option B uses lowercase 'cancel' which won't match if the text is 'Cancel'. Option B includes spaces which must match exactly, so it won't match if the button text has no spaces.
❓ locator
advanced2:00remaining
Which XPath locator correctly selects a
containing exact text 'Error 404'?
Choose the XPath expression that selects a
element whose text content is exactly 'Error 404'.
Attempts:
2 left
💡 Hint
Exact text matching requires exact string including case and spaces.
✗ Incorrect
Option A matches exactly 'Error 404'. Option A matches any div containing 'Error 404' but not necessarily exact text. Options A and C have incorrect text strings and will not match.
🔧 Debug
advanced2:00remaining
Why does this XPath fail to find the element?
Given the XPath
//span[text()='Login'] does not find the element, but the element's visible text is 'Login'. What is the likely cause?Selenium Python
<span> Login </span>
Attempts:
2 left
💡 Hint
Check for spaces around the text inside the element.
✗ Incorrect
XPath text() matches exact text including spaces. If the element text is ' Login ' with spaces, text()='Login' will not match.
❓ framework
expert3:00remaining
Which Selenium Python code snippet correctly waits for a button with exact text 'Submit' to be clickable?
Select the correct code snippet that waits up to 15 seconds for a button with text 'Submit' to be clickable using Selenium WebDriverWait and XPath.
Attempts:
2 left
💡 Hint
Use exact text match and correct XPath syntax.
✗ Incorrect
Option D uses correct XPath with exact text and correct syntax. Option D misses a closing bracket causing syntax error. Option D uses wrong case 'submit'. Option D includes spaces that may not match the actual button text.