JS Testing Academy · QA Demo Site

Progress Bar

Start it, stop it halfway, reset it. A good exercise for waiting until a value reaches a target instead of sleeping.

0%

Practice tasks

  1. Start the bar and wait until it reaches 100% with an explicit wait, then assert the complete message.
  2. Start it, wait until the value is above 25%, click Stop and assert it stops moving.
  3. After it completes, click Reset and assert the value goes back to 0%.
  4. 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%");