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
4,165 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,490 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 4, 2019 in Selenium by Abha
• 28,140 points
2,547 views
+2 votes
3 answers

How can we handle authentication popup in Selenium WebDriver using Java

1) By passing user credentials in URL. String ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
28,353 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
2,674 views
0 votes
3 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 Mar 1, 2020 in Selenium by anuj
28,626 views
0 votes
2 answers

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,500 points
12,619 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,572 views
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,910 points
6,629 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,519 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,490 points
5,934 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,490 points
2,599 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP