Handling calendar popup using Selenium WebDriver

0 votes

I was selecting a date from a calendar popup like 14/08/2017 from calendar using Selenium WebDrive? How to select it? Any suggestions

Below is the code I tried:

package com.Automation;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class DemoDate {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.yatra.com/");
        driver.findElement(By.id("//div[2]/ul[3]/li[1]/i")).click();
        driver.findElement(By.id("a_2015_4_25")).click();
    }
}

Apr 17, 2018 in Selenium by jack
2,545 views
Use Select class

1 answer to this question.

0 votes

You are selecting wrongly your elements in your code, as you are selecting an element by id passing an xpath to the function, it should be like this:

//....

driver.findElement(By.xpath("//div[2]/ul[3]/li[1]/i")).click();

driver.findElement(By.id(' a_2017_8_14'')).click();

//...

You can use ID for clicking it:

driver.findElement(By.id('a_2017_8_14')).click(); //use this format a_yyyy_m_d


you can also go back or forward by clicking the calendar arrows:

driver.findElement(By.className('js_btnNext')).click() // click the "next" arrow

driver.findElement(By.className('js_btnPrev')).click() // click the "prev" arrow

note that calendar must be visible when you click the day.

answered Apr 17, 2018 by Shubham
• 13,380 points

Related Questions In Selenium

0 votes
1 answer

Automation script for handling Calendar on a webpage using Selenium Webdriver?

Hi Shruti, here's the automation script for ...READ MORE

answered Jun 3, 2019 in Selenium by Abha
• 27,930 points
770 views
+2 votes
2 answers

How can we handle authentication popup in Selenium WebDriver using Java

You can use below code for selenium ...READ MORE

answered Jun 21 in Selenium by TEJAS KIRAN RATHI
16,500 views
0 votes
1 answer

Handling pop up in Chrome using Selenium WebDriver

AutoIt Window Information Tool do not recognize ...READ MORE

answered Jun 11, 2018 in Selenium by Meci Matt
• 9,460 points
1,224 views
0 votes
2 answers

Click Allow on Show Notifications popup using Selenium Webdriver

Try this: Robot robot = new Robot(); robot.delay(5000); robot.keyPress(KeyEvent.VK_TAB); robot.keyPress(KeyEvent.VK_ENTER); hope this ...READ MORE

answered Feb 29 in Selenium by anuj
13,909 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,165 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,378 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,890 points
2,530 views
0 votes
1 answer

Downloading *.jar file from http:// seleniumhq.org using Selenium WebDriver

For Selenium Standalone Server: profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/java-archive"); If downloading ...READ MORE

answered Apr 17, 2018 in Selenium by Shubham
• 13,380 points
1,914 views
0 votes
1 answer

30 min Wait on a page and then perform any Operation using Selenium Webdriver

Implicit wait tells webdriver to poll the ...READ MORE

answered Apr 19, 2018 in Selenium by Shubham
• 13,380 points
484 views