Recall & Review
beginner
What is a Custom ExpectedCondition in Selenium?
A Custom ExpectedCondition is a user-defined condition that Selenium waits for before proceeding. It helps handle specific scenarios not covered by built-in conditions.
Click to reveal answer
intermediate
How do you create a Custom ExpectedCondition in Selenium Java?
You create a Custom ExpectedCondition by implementing the ExpectedCondition<T> interface and overriding the apply method with your condition logic.
Click to reveal answer
beginner
Why use Custom ExpectedConditions instead of Thread.sleep()?
Custom ExpectedConditions wait only as long as needed for a condition, making tests faster and more reliable than fixed waits like Thread.sleep().
Click to reveal answer
intermediate
Example: What does this Custom ExpectedCondition do?
ExpectedCondition<Boolean> elementHasText = driver -> {
WebElement el = driver.findElement(By.id("message"));
return el.getText().contains("Success");
};This condition waits until the element with id 'message' contains the text 'Success'. It returns true when the text is found, otherwise false.
Click to reveal answer
beginner
What method do you use to apply a Custom ExpectedCondition in Selenium?
Use WebDriverWait's until() method, passing your Custom ExpectedCondition to wait until it returns true or a value.
Click to reveal answer
What interface must you implement to create a Custom ExpectedCondition in Selenium Java?
✗ Incorrect
Custom ExpectedConditions require implementing the ExpectedCondition interface.
Which method do you override when creating a Custom ExpectedCondition?
✗ Incorrect
The apply method contains the logic to check the condition.
Why is using Custom ExpectedConditions better than Thread.sleep()?
✗ Incorrect
Custom ExpectedConditions wait dynamically, improving test speed and reliability.
What does WebDriverWait.until() do with a Custom ExpectedCondition?
✗ Incorrect
until() waits for the condition to be met or timeout.
Which of these is a valid use case for a Custom ExpectedCondition?
✗ Incorrect
Custom ExpectedConditions are useful for waiting on specific element states like text content.
Explain how to create and use a Custom ExpectedCondition in Selenium Java.
Think about the interface and method you need to write, then how to wait for it.
You got /4 concepts.
Why should you prefer Custom ExpectedConditions over fixed waits like Thread.sleep() in test automation?
Consider how waiting smarter helps tests run better.
You got /4 concepts.