Challenge - 5 Problems
Element State Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Check if a button is enabled using Selenium
What will be the output of this code snippet when the button is enabled on the page?
Selenium Python
from selenium import webdriver from selenium.webdriver.common.by import By # Assume driver is already initialized and page loaded button = driver.find_element(By.ID, 'submit-btn') print(button.is_enabled())
Attempts:
2 left
💡 Hint
The is_enabled() method returns True if the element is enabled and can be interacted with.
✗ Incorrect
The is_enabled() method returns a boolean indicating if the element is enabled. Since the button is enabled, it returns True.
❓ assertion
intermediate2:00remaining
Assert that a checkbox is selected
Which assertion correctly verifies that a checkbox with id 'agree' is selected?
Selenium Python
checkbox = driver.find_element(By.ID, 'agree')Attempts:
2 left
💡 Hint
Use the method that checks if the element is selected.
✗ Incorrect
The is_selected() method returns True if the checkbox is checked. The assertion verifies this condition.
🔧 Debug
advanced2:00remaining
Identify the error in checking if an element is displayed
What error will this code raise when the element with id 'hidden-div' is not present on the page?
Selenium Python
element = driver.find_element(By.ID, 'hidden-div') print(element.is_displayed())
Attempts:
2 left
💡 Hint
Check what happens when find_element cannot find the element.
✗ Incorrect
find_element raises NoSuchElementException if the element is not found. The is_displayed() method is not reached.
🧠 Conceptual
advanced2:00remaining
Understanding difference between is_displayed() and is_enabled()
Which statement correctly describes the difference between is_displayed() and is_enabled() methods in Selenium?
Attempts:
2 left
💡 Hint
Think about visibility versus interactivity.
✗ Incorrect
is_displayed() returns True if the element is visible on the page. is_enabled() returns True if the element can be interacted with (not disabled).
❓ framework
expert3:00remaining
Best practice for waiting until a checkbox is selected
Which Selenium WebDriverWait usage correctly waits until a checkbox with id 'subscribe' is selected?
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 wait = WebDriverWait(driver, 10)
Attempts:
2 left
💡 Hint
Use the expected condition that waits for selection state.
✗ Incorrect
element_to_be_selected waits until the element is selected. Other options wait for visibility, clickability, or presence but not selection.