0

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?

  • This is not related to that dynamic ID issue about 'NoSuchElementException'. This is a different question related to "ElementNotVisibleException". – Nirmani Nayanathara Apr 30 '19 at 08:09
  • I don't see this as a duplicated question. – Nirmani Nayanathara Apr 30 '19 at 08:09
  • @DebanjanB : Please be kind enough to unmark this question from "duplicate" state. I need the answer for this question. – Nirmani Nayanathara Apr 30 '19 at 09:30
  • Do you realize 1)Both the question suffers from the same issue of handling dynamic elements? 2)You spoke about `Start Date` and `End Date` but you havn't provided the relevant HTML for both of them. 3)You haven't replied back to the counter questions asked in your previous question. 4) You have failed to give the credit to the contributors trying to help you out in your previous question? – undetected Selenium Apr 30 '19 at 09:45
  • 1
    Additionally, yelling _NOT DUPLICATE_ doesn't makes a question unique rather you need to show us how this question id different from the dup target. – undetected Selenium Apr 30 '19 at 09:50
  • I am totally new to test automation and Selenium, which I am still a beginner and self studying. Also I haven't had previous experience with stackoverflow; my previous question which you were referring to (https://stackoverflow.com/questions/55811441/element-id-changesnot-static-in-some-web-pages-when-inspecting-elements-duri) is the very FIRST question I've ever posted in stackoverflow. Your last comment in that question was not that clear to me as I am a beginner. That's the reason why I failed to reply for the moment(but I was planning to reply/give credits after figuring out the solution). – Nirmani Nayanathara Apr 30 '19 at 10:08
  • Why I provided HTML code only for the End Date is because I got the issue only for 'End Date' selection. For, 'Start Date' it worked fine. But since you have mentioned it, I edited my question with the HTML codes for both Start and End dates. Thanks! – Nirmani Nayanathara Apr 30 '19 at 10:10

0 Answers0