Progress Bar
Start it, stop it halfway, reset it. A good exercise for waiting until a value reaches a target instead of sleeping.
0%
Progress complete
Practice tasks
- Start the bar and wait until it reaches 100% with an explicit wait, then assert the complete message.
- Start it, wait until the value is above 25%, click Stop and assert it stops moving.
- After it completes, click Reset and assert the value goes back to 0%.
- Assert the button text changes between Start and Stop.
Sample automation code
driver.findElement(By.id("start-stop")).click();
new WebDriverWait(driver, Duration.ofSeconds(30)).until(
ExpectedConditions.textToBePresentInElementLocated(By.id("progress-bar"), "100%"));
Assert.assertTrue(driver.findElement(By.id("progress-complete")).isDisplayed());
driver.findElement(By.id("reset-progress")).click();
Assert.assertEquals(driver.findElement(By.id("progress-bar")).getText(), "0%");
await page.getByTestId('start-stop').click();
await expect(page.getByTestId('progress-bar')).toHaveText('100%', { timeout: 30000 });
await expect(page.getByTestId('progress-complete')).toBeVisible();
await page.getByTestId('reset-progress').click();
await expect(page.getByTestId('progress-bar')).toHaveText('0%');