0
0
Selenium Pythontesting~20 mins

Find element by ID in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ID Locator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
locator
intermediate
2: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"?
Adriver.find_element(By.NAME, "submit-btn")
Bdriver.find_element_by_id("submit-btn")
Cdriver.find_element(By.CLASS_NAME, "submit-btn")
Ddriver.find_element(By.ID, "submit-btn")
Attempts:
2 left
💡 Hint
Use the modern Selenium syntax with By.ID for locating by ID.
assertion
intermediate
2: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")
Aassert element.is_displayed() == True
Bassert element.is_enabled() == False
Cassert element.text == ""
Dassert element.get_attribute('visible') == 'true'
Attempts:
2 left
💡 Hint
Use the Selenium method that checks if an element is visible.
Predict Output
advanced
2: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")
Aselenium.common.exceptions.NoSuchElementException
BAttributeError
CNo error, returns None
DTimeoutException
Attempts:
2 left
💡 Hint
Think about what Selenium does when it cannot find an element immediately.
🔧 Debug
advanced
2: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")
AThe element is disabled, so find_element cannot find it
BThe element is inside an iframe and driver did not switch to it
CThe ID "search-box" is misspelled in the code
DThe page has not fully loaded, so the element is not present yet
Attempts:
2 left
💡 Hint
Think about elements inside frames and how Selenium handles them.
framework
expert
3: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?
Adriver.find_element(By.ID, "submit").click() # No wait
B
time.sleep(10)
driver.find_element(By.ID, "submit").click()
CWebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "submit"))).click()
D
driver.implicitly_wait(10)
driver.find_element(By.ID, "submit").click()
Attempts:
2 left
💡 Hint
Use explicit waits with expected conditions for reliable interaction.