Recall & Review
beginner
What is an explicit wait in Selenium WebDriver?
An explicit wait tells WebDriver to wait for a certain condition to happen before continuing. It waits for a specific element or condition for a set time.
Click to reveal answer
beginner
How do you create an explicit wait using WebDriverWait in Java?
You create a WebDriverWait object with the driver and timeout, then use it with ExpectedConditions to wait for a condition, like this:<br>
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));<br>wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("elementId")));
Click to reveal answer
intermediate
Why is explicit wait better than Thread.sleep()?
Explicit wait waits only as long as needed for a condition, making tests faster and more reliable. Thread.sleep() always waits the fixed time, which can slow tests and cause failures.
Click to reveal answer
intermediate
What happens if the condition in WebDriverWait is not met within the timeout?
If the condition is not met in the given time, WebDriverWait throws a TimeoutException, which means the test will fail at that point.
Click to reveal answer
beginner
Give an example of waiting for an element to be clickable using explicit wait.
Example:<br>
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));<br>WebElement button = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.submit")));
button.click();
Click to reveal answer
What does WebDriverWait do in Selenium?
✗ Incorrect
WebDriverWait waits for a condition like element visibility or clickability before continuing.
Which exception is thrown if WebDriverWait times out?
✗ Incorrect
TimeoutException is thrown when the wait condition is not met within the timeout.
Which method is used with WebDriverWait to wait for an element to be visible?
✗ Incorrect
visibilityOfElementLocated waits until the element is visible on the page.
Why is explicit wait preferred over implicit wait?
✗ Incorrect
Explicit wait targets specific conditions, making tests more precise and reliable.
How do you specify the timeout duration in WebDriverWait in Java?
✗ Incorrect
In modern Selenium Java, Duration.ofSeconds() is used to set the timeout.
Explain how to use explicit wait with WebDriverWait to wait for an element to become clickable.
Think about waiting for a button before clicking it.
You got /4 concepts.
Describe the difference between explicit wait and implicit wait in Selenium.
Consider how each wait affects test speed and reliability.
You got /5 concepts.