Showing posts with label datepicker. Show all posts
Showing posts with label datepicker. Show all posts

Tuesday, May 20, 2014

Selecting a date from Datepicker using Selenium WebDriver / Javascript code to pass date in datepicker

We can dynamically pass the date in Date picker field instead of selecting the date from datepicker calender.


WebElement date_element = driver.findElement(By.id(locator));
          

((JavascriptExecutor)driver).executeScript("arguments[0].value=arguments[1]", date_element, date);


Initialise the variable date as string and assign the value in required format. 
e.g String date ;
date = "01 May 2014"