I am facing difficulty in selecting today's date and the current time plus 15 minutes from the date picker using Selenium.
The code I have written for the date selection is not working. Here is the code snippet:
DateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy hh:mm a");
System.out.println("Format defined");
Date date2 = new Date();
System.out.println("Date object creation");
String today = dateFormat2.format(date2);
WebElement dateWidget = driver.findElement(By.xpath(".//*[@class='xdsoft_calendar']"));
System.out.println("Calendar web element");
List<WebElement> columns=dateWidget.findElements(By.tagName("div"));
System.out.println("listing web element");
System.out.println(today);
//comparing the text of cell with today's date and clicking it.
for (WebElement cell : columns)
{
System.out.println("In for loop"+cell.getText());
if (cell.getText().equals(today))
{
System.out.println("inside if");
System.out.println(today);
cell.click();
break;
}
}
Date picker https://i.sstatic.net/9igbs.png
<div class="xdsoft_calendar">
<table>
<thead>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
</thead>
<tbody>
<tr>
<td data-date="28" data-month="9" data-year="2018" class="xdsoft_date xdsoft_day_of_week0 xdsoft_date xdsoft_disabled xdsoft_other_month xdsoft_weekend">
<div>28</div>
</td>
<td data-date="29" data-month="9" data-year="2018" class="xdsoft_date xdsoft_day_of_week1 xdsoft_date xdsoft_disabled xdsoft_other_month">
<div>29</div>
</td>
<td data-date="30" data-month="9" data-year="2018" class="xdsoft_date xdsoft_day_of_week2 xdsoft_date xdsoft_disabled xdsoft_other_month">
<div>30</div>
</td>
</tr>
</tbody>
</table>
</div>
Note: 1. The expected outcome is to be able to select today's date and the current time plus 15 minutes from the date picker. 2. I am finding this task very challenging, any assistance would be greatly appreciated.