I have Jquery calender in my application. I have task to select dates from different months using Selenium, but I can do only previous month and forward month. Actually I need to select dates from random months by specifying the date and month as input. If there is a way to achieve it let me know.
**My code for Selecting Previous Month date.**
public static void Date_Picker(String datetoselect,String Xpath,String month) {
// Click on the Given Calender Button
driver.findElement(By.xpath(Xpath)).click();
driver.findElement(By.xpath(“//div[@id=’ui-datepicker-div’]/div/a[1]”)).click();
WebElement Month = driver.findElement(By.xpath(“//div[@id=’ui-datepicker-div’]/div/div[@class=’ui-datepicker-title’]/span”));
String Month_Message = Month.getText();
if(Month_Message.contains(month))
{
WebElement dateWidget = driver.findElement(By.className(“ui-datepicker-calendar”));
List<WebElement> rows=dateWidget.findElements(By.tagName(“tr”));
List<WebElement> columns=dateWidget.findElements(By.tagName(“td”));
for (WebElement cell: columns){
if (cell.getText().equals(datetoselect)){
cell.findElement(By.linkText(datetoselect)).click();
break;
}
}
}
Source: Read More