-2

I tried to click on from-date textbox to select the From-Date but I am not able to do so for "opensource-demo.orangehrmlive.com". Dashboard > Apply leave

driver.findElement(By.id("applyleave_txtFromDate").click();
Select secMonth = new Select(driver.findElement(By.xpath("//div[@class='ui-datepicktitle']/select[1]")));
        secMonth.selectByVisibleText("Jan"); Select secYear = new Select(driver.findElement(By.xpath("//div[@class='ui-datepicker-title']/select[2]")));
        secYear.selectByVisibleText("2021");
        
    java.util.List<WebElement> dates = driver.findElements(By.xpath("//td[@data-handler='selectDay']"));
    int count = dates.size();
    for(int i=0;i<count;i++)
    {
        String ReqD = dates.get(i).getText();
        if(ReqD.equalsIgnoreCase("2"))
        {
            dates.get(i).click();
            break;
        }
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Ziniya
  • 9
  • 5

2 Answers2

0

it does not work?

String someDate = "2020-01-02";
WebElement fromDate = driver.findElement(By.id("applyleave_txtFromDate");
fromDate.click();
fromDate.sendKeys(someDate);
fromDate.sendKeys(Keys.TAB);
  • Can I not select the Month/Year /date from the calendar ??? do we have to store the date in a string and pass? – Ziniya Dec 21 '20 at 13:25
  • Of course, you can do that, you can select each item .... you need to map each one (select, button, link ....) and it will take more effort to do that. It is necessary? – Fernando Oliveira Dec 21 '20 at 21:20
  • yes but I am not able to even click on the map icon against the Fromdate by using .click() – Ziniya Dec 22 '20 at 09:16
0

I would recommend for you to use AppConstants to add all final values to it. Then it will be easier to pass it using String (example: public static final String DATE_VALUE = "12/22/2020";) I use this approach for automation testing, because of you are going to use this script for long run as a regression testing for your framework, it will not pass when the calendar month will change. You will have to update your script. But if you will pass it within String value, your script will not need modifications.

tifoso
  • 58
  • 6