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
1,378 views

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,290 points

Related Questions In Selenium

0 votes
1 answer
+2 votes
1 answer

How can we handle authentication popup in Selenium WebDriver using Java

The Alert Method, authenticateUsing() lets us skip ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
6,565 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,420 points
641 views
0 votes
1 answer

Click Allow on Show Notifications popup using Selenium Webdriver

Create a instance of ChromeOptions class ChromeOptions options ...READ MORE

answered Jun 20, 2018 in Selenium by Samarpit
• 5,130 points
5,558 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,090 points
577 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,130 points
898 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,130 points
565 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,290 points
372 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,290 points
120 views