Challenge - 5 Problems
Advanced Selenium Mastery
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 wait code?
Consider this Selenium Python code snippet that waits for an element to be clickable before clicking it. What will be printed if the element is not clickable within 5 seconds?
Selenium Python
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By try: element = WebDriverWait(driver, 5).until( EC.element_to_be_clickable((By.ID, "submit-btn")) ) element.click() print("Clicked") except Exception as e: print("Timeout")
Attempts:
2 left
💡 Hint
Think about what happens when the wait condition is not met within the timeout.
✗ Incorrect
If the element is not clickable within 5 seconds, WebDriverWait throws a TimeoutException, which is caught by the except block, printing 'Timeout'.
❓ assertion
intermediate1:30remaining
Which assertion correctly verifies the page title contains 'Dashboard'?
You want to check that the page title includes the word 'Dashboard' using Python's unittest assertions. Which option is correct?
Attempts:
2 left
💡 Hint
Check which assertion method checks for substring presence.
✗ Incorrect
assertIn checks if the first argument is contained in the second. Here, it verifies 'Dashboard' is part of driver.title.
❓ locator
advanced1:30remaining
Which locator is best to find a button with dynamic ID but fixed text 'Submit'?
The button's ID changes every time the page loads, but its visible text is always 'Submit'. Which Selenium locator strategy is best to find this button reliably?
Attempts:
2 left
💡 Hint
Think about locating elements by visible text when IDs are dynamic.
✗ Incorrect
Using XPath with text() matches the button by its visible text, which is stable, unlike dynamic IDs.
🔧 Debug
advanced2:00remaining
Why does this Selenium test fail to find the element?
This code tries to find a button by ID and click it, but raises NoSuchElementException. What is the likely cause?
Selenium Python
button = driver.find_element(By.ID, 'login-btn')
button.click()Attempts:
2 left
💡 Hint
Check if the element is inside a frame or iframe.
✗ Incorrect
If the element is inside an iframe, Selenium cannot find it until you switch the driver's context to that iframe.
❓ framework
expert2:30remaining
What is the main advantage of using Page Object Model (POM) in Selenium tests?
Why do advanced Selenium test suites use the Page Object Model pattern?
Attempts:
2 left
💡 Hint
Think about how POM helps when page layout changes.
✗ Incorrect
POM organizes locators and actions in classes representing pages, so changes in UI require updates only in one place, making tests easier to maintain.