Replace sleeps with explicit waits
beginner Waits Challenge 6 of 13
The checkout helper is slow and still fails about one run in ten on CI. Replace the hard-coded sleeps with explicit waits.
Requirements
- Remove every
Thread.sleepand the implicit wait. - Create one
WebDriverWaitwithDuration.ofSeconds(10). - Wait for each button with
ExpectedConditions.elementToBeClickablebefore clicking it. - Wait for the confirmation with
ExpectedConditions.visibilityOfElementLocated(ortextToBePresentInElementLocated) before asserting on its text.
Expected output
The method uses one `WebDriverWait(driver, Duration.ofSeconds(10))`, waits for each button with `elementToBeClickable` and for the confirmation with `visibilityOfElementLocated`, and contains no `Thread.sleep` or implicit wait.
Checks (5)
- ○No Thread.sleep
- ○Does not mix in an implicit wait
- ○Creates a WebDriverWait with a Duration timeout
- ○Waits for buttons to be clickable
- ○Waits for the confirmation to be visible
Solution.javaValidated · not executed
Ctrl/⌘ + Enter to validate · your code is saved in this browser
Results
Validate your code against the checks.