I’m trying to get the scroll time of a carousel. I tried to take time when 1st element is selected and time when 2nd element is selected, then deduct 2nd time from 1st time and get the duration.
Below is my code.
//list of carousel button
List<WebElement> button = driver.findElements(By.xpath(“//ul/li/button”));
//calendar instance
Calendar calendar = Calendar.getInstance();
//start time
int scrollStartTime = 0 ;
//end time
int scrollEndTime = 0 ;
for(int btn=0;btn<button.size();btn++) {
if(button.get(0).isSelected()) {
//get start time in mill seconds
long startTime = calendar.getTimeInMillis();
//convert to int
scrollStartTime = (int)startTime;
System.out.println(startTime);
}if(button.get(1).isSelected()) {
//get end time
long endTime = calendar.getTimeInMillis();
//convert to int
scrollEndTime = (int)endTime;
System.out.println(endTime);
}
}
//get the time gap take to change images
int scrollerTime = scrollEndTime – scrollStartTime ;
System.out.println(scrollerTime);
I am not getting any out put. There are no errors. Can some one guide me to get the out put?