//element selectors
@FindBy(xpath = "//div[@id='carouselExampleCaptions']")
private WebElement carouselElementContainer;
@FindBy(xpath = "//div[@id='carouselExampleCaptions']//li"div[@class='carousel-inner']/div")
private List<WebElement> carouselElements;
(...)
public void deltaTimeForCarouselElementSelect(){
//site with carousel that automatically switch images
driver.get("https://getbootstrap.com/docs/4.0/components/carousel/");
WebDriverWait driverWait = new WebDriverWait(driver, Duration.of(15, ChronoUnit.SECONDS));
driverWait.until(ExpectedConditions.visibilityOf(carouselElementContainer));
driverWait.until(ExpectedConditions.attributeContains(carouselElements.get(0), "class", "active""carousel-item active"));
double time1 = getMilliSecTime();
System.out.printf("Time for first event: %s milliseconds %n", time1);
driverWait.until(ExpectedConditions.attributeContains(carouselElements.get(carouselElements.size() - 1), "class", "active"));
double time2 = getMilliSecTime();
System.out.printf("Time for last event: %s milliseconds %n", time2);
double DeltaInMilli = time2 - time1;
System.out.printf("Time that took between the two events - %f milliseconds %n", DeltaInMilli);
}
private long getMilliSecTime(){
Date date = new Date();
return date.getTime();
}