Challenge - 5 Problems
Explicit Waits 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 Selenium explicit wait code?
Consider the following Selenium Python code snippet using explicit wait. What will be printed?
Selenium Python
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class DummyElement: def __init__(self): self.text = "Loaded" # Mock driver and wait for demonstration class MockDriver: def find_element(self, by, value): return DummyElement() driver = MockDriver() try: element = WebDriverWait(driver, 5).until( EC.presence_of_element_located((By.ID, "my-element")) ) print(element.text) except Exception: print("Timeout")
Attempts:
2 left
💡 Hint
Think about what the mock driver returns and how WebDriverWait uses it.
✗ Incorrect
The mock driver returns a DummyElement with text 'Loaded'. The explicit wait condition presence_of_element_located returns this element immediately, so 'Loaded' is printed.
❓ assertion
intermediate1:30remaining
Which assertion correctly verifies element visibility after explicit wait?
You want to assert that an element with ID 'submit-btn' is visible after waiting explicitly. 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) element = wait.until(EC.visibility_of_element_located((By.ID, 'submit-btn')))
Attempts:
2 left
💡 Hint
Visibility means the element is displayed on the page.
✗ Incorrect
The explicit wait returns a visible element, so asserting is_displayed() == True confirms visibility.
❓ locator
advanced2:00remaining
Which locator is best for waiting for a button with text 'Submit' to be clickable?
You want to wait explicitly until a button with visible text 'Submit' is clickable. Which locator and condition combo is best?
Attempts:
2 left
💡 Hint
Consider which locator matches exact button text and which condition ensures clickability.
✗ Incorrect
Option A uses XPath to match button text exactly and waits for the button to be clickable, which is the best approach.
🔧 Debug
advanced2:00remaining
Why does this explicit wait code raise TimeoutException?
This code raises TimeoutException even though the element is present. Why?
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, 5) wait.until(EC.visibility_of_element_located((By.ID, 'loading-spinner')))
Attempts:
2 left
💡 Hint
Presence and visibility are different conditions.
✗ Incorrect
The element exists in the DOM but is hidden, so visibility_of_element_located never returns true before timeout.
❓ framework
expert3:00remaining
How to implement a custom explicit wait condition for element attribute value?
You want to wait until an element with ID 'status' has attribute 'data-state' equal to 'ready'. Which custom expected condition implementation is correct?
Attempts:
2 left
💡 Hint
Custom expected conditions must be callable classes with __call__ and use *self.locator.
✗ Incorrect
Option A correctly defines a callable class with __init__ and __call__, uses *self.locator to unpack, and returns the attribute check.