0

I'm new to automation and I'm trying to validate the calendar in the website https://www.spicejet.com/. What i want to achieve >> Select the date 10th septemeber through automation.

I have managed to find the months elements and put them in a list. While i iterate through the list i check if the months match September and if not the button to show the next month gets clicked.

THE PROBLEM>> While the date gets selected as intended, the button to reach september is clicked more than needed and it ends up reaching months ahead(For eg, it reaches december). I know why that is happening, its due to the fact that two Months are being displayed at the same page and I'm checking one month and clicking on the next button. I cant find a solution as to how to check two months from list and then click on the next button to get to the next month.

 List<WebElement> monthPicker = driver
            .findElements(By.xpath("//div[@class='css-76zvg2 r-homxoj r-adyw6z r-1kfrs79']"));

    for (WebElement month : monthPicker) {
        if (month.getText().equalsIgnoreCase("September 2022")) {
            break;
        } else {

            driver.findElement(By.xpath(
                    "//div[@class='css-1dbjc4n r-14lw9ot r-11u4nky r-rs99b7 r-6koalj r-eqz5dr r-1pi2tsx r-pm9dpa r-1knelpx r-13qz1uu']/div[1]"))
                    .click();

        }
    }
AmeyaG
  • 176
  • 1
  • 1
  • 10
  • Have you tried executing simple vanilla javascript for that? https://stackoverflow.com/questions/28729634/set-values-in-input-type-date-and-time-in-javascript – HerrAlvé Mar 07 '22 at 13:12
  • @AlveMonke I'm not sure how that helps. Please elaborate. I'm new to this. – AmeyaG Mar 07 '22 at 13:14

0 Answers0