How to Select Date from DatePicker in Selenium Webdriver How to Select Date from DatePicker in Selenium Webdriver

site de rencontre franГ§ais gratuit 2015 In this post, we’ll learn how to handle date time picker controls like jQuery date picker and Kendo date picker using Selenium Webdriver.

sitios de citas ecuador I will use JQuery Date picker for example and you can take any example because approach will remain same.

Full Article Below image is an example of Date picker which is JQuery widget

nsi online dating contact number Link for above Calendar:

here early closure bei binären optionen Steps to follow:

Step 1- Click on calendar

Step 2 – Get the month and year from the Calander by getText() method.

Step 3- Compare the month & Year with given month & Year. Here I want to Select 15-January-2018, but the extracted month and year is October 2017.

Step 4- If month & Year does not matches then Click on next button and repeat Step no 3 unless it found the match.

Step 5- Once month & Year matches, it’s time to select day. Using for loop get text of all elements using if else condition we will check specific date

Step 6- If date is matched then click and break the loop.

You are done !!

package pack7;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class CalendarProgram {
  public static void main(String[] args) throws InterruptedException {
  WebDriver driver = new FirefoxDriver();
  WebElement calElement=driver.findElement("datepicker"));;
  String date = "15-January-2018";
  String spilitter[]=date.split("-");
  String eday = spilitter[0];
  String emonth = spilitter[1];
  String eYear = spilitter[2];
  String oMonth=driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/div/div/span[1]")).getText();
  String oYear=driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/div/div/span[2]")).getText();
  WebElement Next = driver.findElement(By.xpath("//span[contains(text(),'Next')]"));// Next Button
  while(!((eYear.contentEquals(oYear)) && (emonth.contentEquals(oMonth))))
    Next = driver.findElement(By.xpath("//span[contains(text(),'Next')]"));
  System.out.println("M here");
  WebElement tBody = driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/table/tbody"));
  List<WebElement> tRow = tBody.findElements(By.tagName("tr"));
  for(int i=1;i<=tRow.size();i++)
    List<WebElement> tColoumn = tRow.get(i).findElements(By.tagName("td"));
    for(int j=1;j<=tColoumn.size();j++)
      String oDay = driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/table/tbody/tr["+i+"]/td["+j+"]/a")).getText();