Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
269 views
by
I'm trying to select date from calendar which is opened in another window, I have already switched focus to new window but it won't select date from calendar.

Written code :

WebElement date = driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div/div[1]/div/div[2]/div[1]/div/input[2]"));

        
        executor.executeScript("arguments[0].click();", date);
        driver.findElement(By.xpath("/html/body/div[6]/div[2]/div/div[2]/div/span[18]")).click();

 

Dev code:

<div class="flatpickr-days" tabindex="-1"><div class="dayContainer"><span class="flatpickr-day prevMonthDay flatpickr-disabled" aria-label="May 31, 2020">31</span><span class="flatpickr-day flatpickr-disabled" aria-label="June 1, 2020">1</span><span class="flatpickr-day today" aria-label="June 2, 2020" aria-current="date" tabindex="-1">2</span><span class="flatpickr-day selected" aria-label="June 3, 2020" tabindex="-1">3</span>
by Master (1.2k points)
Do you have any iframe in newly opened window? You may have to switch to iframe in the newly opened window.

Also, on your code, I do not see you switching.

Please log in or register to answer this question.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...