Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a FluentWait with a timeout of 30 seconds.
Selenium Java
FluentWait<WebDriver> wait = new FluentWait<>(driver).withTimeout(Duration.ofSeconds([1])); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a timeout value too small causing premature timeout.
Forgetting to use Duration.ofSeconds.
✗ Incorrect
The timeout is set to 30 seconds using Duration.ofSeconds(30).
2fill in blank
mediumComplete the code to set the polling interval to 5 seconds.
Selenium Java
wait.pollingEvery(Duration.ofSeconds([1])); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting polling interval longer than timeout.
Using wrong Duration method.
✗ Incorrect
Polling interval is set to 5 seconds using Duration.ofSeconds(5).
3fill in blank
hardFix the error in the code to ignore NoSuchElementException during wait.
Selenium Java
wait.ignoring([1].class);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Ignoring wrong exception causing wait to fail early.
Forgetting to add .class after exception name.
✗ Incorrect
Ignoring NoSuchElementException allows the wait to continue polling if element is not found yet.
4fill in blank
hardFill both blanks to create a FluentWait that waits 20 seconds and polls every 2 seconds.
Selenium Java
FluentWait<WebDriver> wait = new FluentWait<>(driver).withTimeout(Duration.ofSeconds([1])).pollingEvery(Duration.ofSeconds([2]));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting polling interval longer than timeout.
Swapping timeout and polling values.
✗ Incorrect
Timeout is 20 seconds and polling interval is 2 seconds as required.
5fill in blank
hardFill all three blanks to create a FluentWait that waits 15 seconds, polls every 3 seconds, and ignores StaleElementReferenceException.
Selenium Java
FluentWait<WebDriver> wait = new FluentWait<>(driver).withTimeout(Duration.ofSeconds([1])).pollingEvery(Duration.ofSeconds([2])).ignoring([3].class);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exception to ignore.
Mixing up timeout and polling values.
✗ Incorrect
Timeout is 15 seconds, polling every 3 seconds, ignoring StaleElementReferenceException as required.