# Automated date field

**URL:** <https://forum.katalon.com/t/automated-date-field/55622>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [June 10, 2021, 10:15am UTC](https://forum.katalon.com/t/automated-date-field/55622 "2021-06-10T10:15:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [June 10, 2021, 3:34pm UTC](https://forum.katalon.com/t/automated-date-field/55622/2 "2021-06-10T15:34:46Z")

</div>

The first thing to do is to right click on the date GUI and review the HTML. Then it depends if you can select a **static** date, or current date (i.e. just click on the “Today” link), or if you need to input a specific date ( **dynamic** ).

> **Maybe try**
>
> I created two objects based on the HTML of OUR Calendar GUI: select\_DatePickerMonth and select\_DatePickerYear. For these two objects, I used a simple xpath for each–again, review **your** HTML.  
> select\_DatePickerMonth  
> `//select[@class="ui-datepicker-month" and @data-handler="selectMonth"]`
> 
> select\_DatePickerYear  
> `//select[@class="ui-datepicker-year" and @data-handler="selectYear"]`
> 
> ```auto
> "click on date input field"
> WebUI.click(findTestObject('myPage/input_ADate'))
> 
> Date todaysDate = new Date()
> dayPart = todaysDate[Calendar.DAY_OF_MONTH]
> monthPart = todaysDate[Calendar.MONTH]
> yearPart = todaysDate[Calendar.YEAR] 
> 
> "set the month"
> WebUI.waitForElementClickable(findTestObject('myPage/select_DatePickerMonth'), 10)
> "get the VALUE of this element"
> WebUI.selectOptionByValue(findTestObject('myPage/select_DatePickerMonth'), monthPart.toString(), false)
> 
> "set the year"
> WebUI.waitForElementClickable(findTestObject('myPage/select_DatePickerYear'), 10)
> "get the LABEL of this element"
> WebUI.selectOptionByLabel(findTestObject('myPage/select_DatePickerYear'), yearPart.toString(), false)
> 
> "set the day"
> WebElement selCalendarTable = driver.findElement(By.xpath('//table[@class="ui-datepicker-calendar"]/tbody'))
> 
> List<WebElement> Rows = selCalendarTable.findElements(By.tagName('tr'))
> 
> Loop:
> for (int i = 0; i < Rows.size(); i++) {
> 
> 'To locate columns(cells) of that specific row'
> List<WebElement> Cols = Rows.get(i).findElements(By.tagName('td'))
> 
> for (int j = 0; j < Cols.size(); j++) {
> 
> if (Cols.get(j).getText().equals(dayPart.toString())) {
> WebUI.comment("found day ${dayPart}" )
> Cols[j].click();
> break Loop;
> }
> }
> }
> 
> ```

---

_[View the full topic](https://forum.katalon.com/t/automated-date-field/55622)._
