package playground; import com.google.common.util.concurrent.Uninterruptibles; import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.time.Duration; import static org.testng.Assert.assertEquals; // http://uitestingplayground.com/home // Go To Progress Bar and wait for it to fully load public class ProgressBar { private WebDriver driver; private WebDriverWait wait; @BeforeClass public void startSession() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("http://uitestingplayground.com/progressbar"); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(3)); wait = new WebDriverWait(driver, Duration.ofSeconds(30)); } @AfterClass public void closeSession() { Uninterruptibles.sleepUninterruptibly(Duration.ofSeconds(2)); // to view result only! driver.quit(); } @Test public void test01_VerifyProgressBar() { WebElement start = driver.findElement(By.id("startButton")); WebElement stop = driver.findElement(By.id("stopButton")); WebElement progress = driver.findElement(By.id("progressBar")); start.click(); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@aria-valuenow='75']"))); stop.click(); Assert.assertEquals(progress.getAttribute("aria-valuenow"), "75"); } }