In accordance with the code supplied, there are a number of hypotheses that I’d consider.
Because you stated that you’re not getting any output I might formulate that this code may not even being executed. The explanation for my assertion depends on the next two items of your code:
//begin time
int scrollStartTime = 0 ;
//finish time
int scrollEndTime = 0 ;
(...)
//get the time hole take to alter pictures
int scrollerTime = scrollEndTime - scrollStartTime ;
System.out.println(scrollerTime);
Because of this even when the listing is empty and your for loop will not be run you no less than would see the quantity zero (0) supplied in your terminal.
Lets assume for now that certainly the zero (0) seems in your terminal however you did not observed, so the difficulty would possibly depend on the for loop. The explanation why is that you just’re are stating that you’ve got a listing of two parts (contemplating that certainly your listing will not be empty) however the time to iterate a 2 factor listing is nearly on the spot, so there’s a excessive change that your code already completed iterating with none of the objects even being chosen, because of this not one of the if statements is executed. (you may want think about using breakpoints to substantiate that)
Since I haven’t got the complete perception of the applying you are attempting to check it’s onerous to offer you a concrete reply however you would possibly wish to change your logic to attend for when the particular occasion happens and seize its time (on this case the particular button is chosen). Beneath I attempt to present a working instance that presumably could remedy your drawback and offer you a solution to the time that it takes to maneuver the carousel. (within the instance as a substitute of a specific factor, I look forward to a component with identified attribute however the precept that you must apply could be very comparable)
Please word that the code supplied under would not comply with the right apply for coding a great automation and it is just to offer a fast instance of what you would possibly do, so think about adapting it to an accurate apply.
//factor selectors
@FindBy(xpath = "//div[@id='carouselExampleCaptions']")
non-public WebElement carouselElementContainer;
@FindBy(xpath = "//div[@id='carouselExampleCaptions']//div[@class="carousel-inner"]/div")
non-public Checklist carouselElements;
(...)
public void deltaTimeForCarouselElementSelect(){
//website with carousel that mechanically swap pictures
driver.get("https://getbootstrap.com/docs/4.0/parts/carousel/");
WebDriverWait driverWait = new WebDriverWait(driver, Period.of(15, ChronoUnit.SECONDS));
driverWait.till(ExpectedConditions.visibilityOf(carouselElementContainer));
driverWait.till(ExpectedConditions.attributeContains(carouselElements.get(0), "class", "carousel-item energetic"));
double time1 = getMilliSecTime();
System.out.printf("Time for first occasion: %s milliseconds %n", time1);
driverWait.till(ExpectedConditions.attributeContains(carouselElements.get(carouselElements.measurement() - 1), "class", "energetic"));
double time2 = getMilliSecTime();
System.out.printf("Time for final occasion: %s milliseconds %n", time2);
double DeltaInMilli = time2 - time1;
System.out.printf("Time that took between the 2 occasions - %f milliseconds %n", DeltaInMilli);
}
non-public lengthy getMilliSecTime(){
Date date = new Date();
return date.getTime();
}
Operating this methodology will present an analogous output because the one displayed under:
Time for first occasion: 1.654638603088E12 milliseconds
Time for final occasion: 1.654638613128E12 milliseconds
Time that took between the 2 occasions - 10040.000000 milliseconds