0
0
Selenium Pythontesting~10 mins

Explicit waits (WebDriverWait) in Selenium Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to wait until the element with ID 'submit' is clickable.

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)
submit_button = wait.until(EC.[1]((By.ID, 'submit')))
Drag options to blanks, or click blank then click option'
Apresence_of_element_located
Balert_is_present
Cvisibility_of_element_located
Delement_to_be_clickable
Attempts:
3 left
💡 Hint
Common Mistakes
Using presence_of_element_located which only checks if element is in DOM, not clickable.
Using alert_is_present which waits for alerts, not elements.
2fill in blank
medium

Complete the code to wait up to 15 seconds for the element with class name 'loading' to disappear.

Selenium Python
wait = WebDriverWait(driver, 15)
wait.until(EC.[1]((By.CLASS_NAME, 'loading')))
Drag options to blanks, or click blank then click option'
Apresence_of_element_located
Bvisibility_of_element_located
Cinvisibility_of_element_located
Delement_to_be_clickable
Attempts:
3 left
💡 Hint
Common Mistakes
Using visibility_of_element_located which waits for element to appear.
Using presence_of_element_located which only checks presence, not visibility.
3fill in blank
hard

Fix the error in the code to wait for an alert to be present.

Selenium Python
wait = WebDriverWait(driver, 5)
alert = wait.until(EC.[1]())
Drag options to blanks, or click blank then click option'
Aalert_is_present
Bvisibility_of_element_located
Cpresence_of_element_located
Delement_to_be_clickable
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a locator to alert_is_present which does not accept any arguments.
Using element conditions for alerts.
4fill in blank
hard

Fill both blanks to wait until the element with name 'username' is visible and enabled.

Selenium Python
wait = WebDriverWait(driver, 20)
element = wait.until(EC.[1]((By.[2], 'username')))
Drag options to blanks, or click blank then click option'
Avisibility_of_element_located
BID
CNAME
Delement_to_be_clickable
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.ID when the element is located by name.
Using visibility_of_element_located which waits for visibility but not necessarily enabled.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that waits for elements with IDs in 'ids' list to be visible, storing them by uppercase ID keys.

Selenium Python
elements = { [1]: wait.until(EC.visibility_of_element_located((By.ID, [2]))) for [3] in ids }
Drag options to blanks, or click blank then click option'
Aid.upper()
Bid
Delement
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'element' as the loop variable instead of 'id'.
Using the wrong key or locator value.