Challenge - 5 Problems
ID Locator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ locator
intermediate2:00remaining
Identify the correct Selenium locator for element by ID
Which of the following Selenium Python commands correctly finds an element by its ID "submit-btn"?
Attempts:
2 left
💡 Hint
Use the modern Selenium syntax with By.ID for locating by ID.
✗ Incorrect
In Selenium 4+, the recommended way to find elements by ID is using driver.find_element(By.ID, "id_value"). The older method find_element_by_id is deprecated. Using CLASS_NAME or NAME will not find by ID.
❓ assertion
intermediate2:00remaining
Check if element found by ID is visible
Given you found an element by ID "login-input", which assertion correctly verifies the element is visible on the page?
Selenium Python
element = driver.find_element(By.ID, "login-input")Attempts:
2 left
💡 Hint
Use the Selenium method that checks if an element is visible.
✗ Incorrect
The is_displayed() method returns True if the element is visible. is_enabled() checks if element is enabled for interaction, not visibility. text and get_attribute('visible') do not reliably indicate visibility.
❓ Predict Output
advanced2:00remaining
Output of Selenium find_element by ID with missing element
What error will this Selenium Python code raise if no element with ID "nonexistent" is found?
Selenium Python
element = driver.find_element(By.ID, "nonexistent")Attempts:
2 left
💡 Hint
Think about what Selenium does when it cannot find an element immediately.
✗ Incorrect
find_element throws NoSuchElementException if the element is not found. It does not return None or raise AttributeError or TimeoutException by default.
🔧 Debug
advanced2:00remaining
Debug why find_element by ID fails
You wrote this code but it fails to find the element by ID "search-box". What is the most likely reason?
Selenium Python
element = driver.find_element(By.ID, "search-box") element.send_keys("test")
Attempts:
2 left
💡 Hint
Think about elements inside frames and how Selenium handles them.
✗ Incorrect
If the element is inside an iframe, Selenium cannot find it unless you switch to that iframe first. Misspelling or page load issues can cause failure but the most common cause is iframe context.
❓ framework
expert3:00remaining
Best practice for waiting for element by ID before interaction
Which Selenium Python code snippet correctly waits up to 10 seconds for an element with ID "submit" to be clickable before clicking it?
Attempts:
2 left
💡 Hint
Use explicit waits with expected conditions for reliable interaction.
✗ Incorrect
Explicit wait with WebDriverWait and expected_conditions ensures the element is clickable before clicking. time.sleep is unreliable and slows tests. Implicit wait waits for presence but not clickability.