Recall & Review
beginner
What is a custom wait condition in Selenium?
A custom wait condition is a user-defined rule that tells Selenium to wait until a specific condition is true before continuing the test. It helps handle cases where built-in waits are not enough.
Click to reveal answer
beginner
How do you create a custom wait condition in Selenium with Python?
You create a function that takes a WebDriver as input and returns True when the condition is met or False otherwise. Then you use WebDriverWait with this function.
Click to reveal answer
beginner
Why use custom wait conditions instead of fixed sleep times?
Custom waits wait only as long as needed, making tests faster and more reliable. Fixed sleeps waste time and can cause flaky tests if the wait is too short or too long.
Click to reveal answer
intermediate
Example of a simple custom wait condition function in Selenium Python?
from selenium.webdriver.common.by import By
def element_has_text(driver):
element = driver.find_element(By.ID, 'message')
return element.text == 'Loaded'
This waits until the element with ID 'message' has text 'Loaded'.Click to reveal answer
beginner
What exception does WebDriverWait raise if the custom condition is not met in time?
It raises a TimeoutException to indicate the wait timed out before the condition became true.
Click to reveal answer
What does a custom wait condition function in Selenium Python return when the condition is met?
✗ Incorrect
The custom wait condition function returns True when the condition is met, signaling WebDriverWait to proceed.
Which Selenium class is used to apply custom wait conditions?
✗ Incorrect
WebDriverWait is used to wait until a custom or built-in condition is true.
What happens if the custom wait condition is not met within the timeout?
✗ Incorrect
If the condition is not met in time, WebDriverWait raises a TimeoutException.
Why are custom wait conditions better than fixed sleep() calls?
✗ Incorrect
Custom waits wait dynamically, improving test speed and reliability.
Which argument does a custom wait condition function receive?
✗ Incorrect
The function receives the WebDriver instance to check page state.
Explain how to implement a custom wait condition in Selenium Python and why it is useful.
Think about waiting for specific page states dynamically.
You got /4 concepts.
Describe what happens when a custom wait condition times out in Selenium tests.
Consider how Selenium signals wait failures.
You got /3 concepts.