Challenge - 5 Problems
CSS Attribute Selector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ locator
intermediate1:30remaining
Identify the correct CSS attribute selector for exact match
Which CSS selector correctly locates an input element with the attribute
type exactly equal to email?Attempts:
2 left
💡 Hint
Remember, the exact match selector uses = inside the brackets.
✗ Incorrect
The selector input[type='email'] matches elements whose type attribute is exactly email. The other selectors match partial values: ^= for starts with, $= for ends with, and *= for contains.
❓ assertion
intermediate1:30remaining
Assertion for element presence using CSS attribute selector
Given the Selenium Python code below, which assertion correctly verifies that an element with
data-test='submit-btn' is present on the page?Selenium Python
element = driver.find_element(By.CSS_SELECTOR, "button[data-test='submit-btn']")Attempts:
2 left
💡 Hint
Check if the element is visible rather than its text or tag.
✗ Incorrect
To verify presence and visibility, element.is_displayed() returns True if the element is visible on the page. Checking text or tag name does not confirm presence.
❓ Predict Output
advanced1:30remaining
Output of Selenium find_elements with CSS attribute selector
What is the output type of the following Selenium Python code snippet?
Selenium Python
elements = driver.find_elements(By.CSS_SELECTOR, "input[name^='user']") print(type(elements))
Attempts:
2 left
💡 Hint
find_elements returns multiple matches, not a single element.
✗ Incorrect
The method find_elements returns a list of WebElement objects matching the selector. Therefore, the type is list.
🔧 Debug
advanced2:00remaining
Identify the error in CSS attribute selector usage
What error will the following Selenium Python code raise?
Selenium Python
element = driver.find_element(By.CSS_SELECTOR, "input[name='user"]")
Attempts:
2 left
💡 Hint
Check the quotes inside the CSS selector string.
✗ Incorrect
The CSS selector string has mismatched quotes causing an invalid selector. Selenium raises InvalidSelectorException when the selector syntax is wrong.
🧠 Conceptual
expert2:00remaining
Choosing the best CSS attribute selector for partial attribute matching
You want to select all
input elements whose id attribute contains the substring email anywhere inside it. Which CSS selector should you use?Attempts:
2 left
💡 Hint
Look for the selector that matches substring anywhere, not just start or end.
✗ Incorrect
The *= operator matches if the attribute contains the substring anywhere. ^= matches start, $= matches end, and = matches exact.