0
0
Selenium Pythontesting~10 mins

Expected conditions 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)
wait.until(EC.[1]((By.ID, 'submit')))
Drag options to blanks, or click blank then click option'
Aelement_to_be_clickable
Bpresence_of_element_located
Calert_is_present
Dvisibility_of_element_located
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 until the page title contains the word 'Dashboard'.

Selenium Python
wait = WebDriverWait(driver, 15)
wait.until(EC.[1]('Dashboard'))
Drag options to blanks, or click blank then click option'
Atitle_matches
Btitle_is
Ctitle_contains
Dtitle_starts_with
Attempts:
3 left
💡 Hint
Common Mistakes
Using title_is which requires exact match of the title.
Using title_matches which is not a standard expected condition.
3fill in blank
hard

Fix the error in the code to wait until an alert is 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
Balert_wait
Cpresence_of_alert
Dalert_present
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent conditions like alert_present or presence_of_alert.
Forgetting to call the condition as a function.
4fill in blank
hard

Fill both blanks to wait until the element with class 'loading' is invisible.

Selenium Python
wait = WebDriverWait(driver, 20)
wait.until(EC.[1]((By.[2], 'loading')))
Drag options to blanks, or click blank then click option'
Ainvisibility_of_element_located
BID
CCLASS_NAME
DCSS_SELECTOR
Attempts:
3 left
💡 Hint
Common Mistakes
Using visibility_of_element_located instead of invisibility.
Using ID locator for a class name.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps element text to its attribute 'href' for all links visible on the page.

Selenium Python
links = driver.find_elements(By.TAG_NAME, 'a')
link_dict = { [1]: [2] for [3] in links if EC.visibility_of([3])(driver) }
Drag options to blanks, or click blank then click option'
Alink.text
Blink.get_attribute('href')
Clink
Delement
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names inconsistent in comprehension.
Not calling get_attribute correctly.
Not filtering visible elements.