I am trying to automate 2 date fields in a web page, "Start Date" and "End Date". But I get org.openqa.selenium.ElementNotVisibleException exception before clicking on "End Date".
HTML:
START DATE:
<td role="gridcell" id="ext-gen3261" title="May 01, 2019" class="x-datepicker-active x-datepicker-cell x-datepicker-selected">
<a role="presentation" hidefocus="on" class="x-datepicker-date" href="#">1</a>
</td>
END DATE:
<td role="gridcell" id="ext-gen3310" title="May 02, 2019" class="x-datepicker-active x-datepicker-cell">
<a role="presentation" hidefocus="on" class="x-datepicker-date" href="#">2</a>
</td>
I could use WebDriverWait for the End Date field and overcome the issue when selecting Start Date is NOT automated. (Only when "End Date" is automated).
driver.findElement(By.id("ext-gen3220")).click(); //id of the calendar icon = 'ext-gen3220'
WebDriverWait wait2 = new WebDriverWait(driver,30);
wait2.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//td[@title='May 02, 2019']")));
driver.findElement(By.xpath("//td[@title='May 02, 2019']")).click();
(Test passed)
But, when I automate selecting both Start Date and End Date, this solution is not working.
driver.findElement(By.id("ext-gen3218")).click(); //id of the start date calendar icon = 'ext-gen3218'
WebDriverWait wait1 = new WebDriverWait(driver, 30);
wait1.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//td[@title='May 01, 2019']")));
driver.findElement(By.xpath("//td[@title='May 01, 2019']")).click();
driver.findElement(By.id("ext-gen3220")).click(); //id of the end date calendar icon = 'ext-gen3220'
WebDriverWait wait2 = new WebDriverWait(driver,30);
wait2.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//td[@title='May 02, 2019']")));
driver.findElement(By.xpath("//td[@title='May 02, 2019']")).click();
Again I get org.openqa.selenium.ElementNotVisibleException exception.
How to resolve this issue which appears only when automating both date fields?