How can I select date from a datepicker div using Selenium Webdriver?

0 votes
How can I select date from a datepicker div using Selenium Webdriver?
Jul 15 in Selenium by Jeevika
97 views

1 answer to this question.

0 votes

Hey Jeevika, you can use following automation script to select a date from a datepicker div in Webdriver:

driver = new FirefoxDriver();

driver.get("http://jqueryui.com/datepicker/");

  driver.switchTo().frame(0);

  driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

  driver.findElement(By.id("datepicker")).click();

  driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

  WebElement dateWidget = driver.findElement(By.id("ui-datepicker-div"));

  List rows=dateWidget.findElements(By.tagName("tr"));

  List columns=dateWidget.findElements(By.tagName("td"));

  for (WebElement cell: columns){

   //Select 10th Date

   if (cell.getText().equals("10")){

   cell.findElement(By.linkText("10")).click();

   break;

   }

  }
answered Jul 15 by Abha
• 24,320 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
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
750 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
995 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
709 views
0 votes
1 answer