How can I create a customised time slot calendar?

 I have customised the UI calendar attached in the screenshot having date and time slots to book some test drives. actually the booked slot div contains some class and available slot contains some class name.

How can I click the next available slot containing the div.

Answered by Al German

I'd actually need a negative example to be completely sure but as I see it there must be either a CSS class to make the cells blue or to make them white. Either way, you can actually do something along the lines of


public static WebElement getFreeSlot(String colorCode)
List slots = driver.findElement(By.cssSelector(".day-body .hour-wrapper"));
for(WebElement slot : slots){
    String colour = slot.getCssValue("background-colour");
    if(color.equals(colorCode))
        return slot;
}
return null;
}

Just pass it the colour code for your background (should be just white but look it up to be safe) and you should get the first, white time slot calendar.



Your Answer

Interviews

Parent Categories