Sure, but remember, the following is designed to handle my particular datepicker functionality, with my own coding conventions (in particular, I make heavy use of what I call “predicate-driven” xpathing), so it will absolutely not work for you as-is. That being said, you could follow the approach and do something similar for your widget:
One of our datepicker widgets looks like this:

Here’s the Page Object that encapsulates all of the functionality for it:
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import com.kms.katalon.core.util.KeywordUtil
import base.util.ElementUtil
public class DatePicker extends Page {
public void clickPreviousMonthButton() {
KeywordUtil.logInfo("Date Picker: Clicking previous month button");
WebElement button = findElement(By.xpath(getPreviousMonthButtonXPath()), defaultTimeout);
button.click();
}
public boolean isPreviousMonthButtonVisible() {
boolean visible = isElementVisible(By.xpath(getPreviousMonthButtonXPath()), defaultTimeout);
return visible;
}
public boolean isPreviousMonthButtonEnabled() {
boolean enabled = isElementEnabled(By.xpath(getPreviousMonthButtonXPath()), defaultTimeout);
return enabled;
}
public void clickNextMonthButton() {
KeywordUtil.logInfo("Date Picker: Clicking next month button");
WebElement button = findElement(By.xpath(getNextMonthButtonXPath()), defaultTimeout);
button.click();
}
public boolean isNextMonthButtonVisible() {
boolean visible = isElementVisible(By.xpath(getNextMonthButtonXPath()), defaultTimeout);
return visible;
}
public boolean isNextMonthButtonEnabled() {
boolean enabled = isElementEnabled(By.xpath(getNextMonthButtonXPath()), defaultTimeout);
return enabled;
}
public void setMonth(final String month) {
KeywordUtil.logInfo("Date Picker: Setting month to " + month);
WebElement dropdown = findElement(By.xpath(getMonthDropdownXPath()), defaultTimeout);
dropdown.click();
WebElement option = findElement(By.xpath(getMonthXPath(getSingleMonthPredicate(month))), defaultTimeout);
option.click();
}
public List<String> getMonths() {
WebElement dropdown = findElement(By.xpath(getMonthDropdownXPath()), defaultTimeout);
dropdown.click();
List<WebElement> options = findElements(By.xpath(getMonthXPath("")), defaultTimeout);
List<String> months = ElementUtil.getTextsFromElements(options, true);
dropdown.click();
return months;
}
public boolean isMonthDropdownVisible() {
boolean visible = isElementVisible(By.xpath(getMonthDropdownXPath()), defaultTimeout);
return visible;
}
public boolean isMonthDropdownEnabled() {
boolean enabled = isElementEnabled(By.xpath(getMonthDropdownXPath()), defaultTimeout);
return enabled;
}
public void setYear(final String year) {
KeywordUtil.logInfo("Date Picker: Setting year to " + year);
WebElement dropdown = findElement(By.xpath(getYearDropdownXPath()), defaultTimeout);
dropdown.click();
WebElement option = findElement(By.xpath(getYearXPath(getSingleYearPredicate(year))), defaultTimeout);
option.click();
}
public List<String> getYears() {
WebElement dropdown = findElement(By.xpath(getYearDropdownXPath()), defaultTimeout);
dropdown.click();
List<WebElement> options = findElements(By.xpath(getYearXPath("")), defaultTimeout);
List<String> years = ElementUtil.getTextsFromElements(options, true);
dropdown.click();
return years;
}
public boolean isYearDropdownVisible() {
boolean visible = isElementVisible(By.xpath(getYearDropdownXPath()), defaultTimeout);
return visible;
}
public boolean isYearDropdownEnabled() {
boolean enabled = isElementEnabled(By.xpath(getYearDropdownXPath()), defaultTimeout);
return enabled;
}
public void clickDay(final String day) {
KeywordUtil.logInfo("Date Picker: Clicking day " + day);
WebElement element = findElement(By.xpath(getDayXPath(getSingleDayPredicate(day))), defaultTimeout);
element.click();
}
public List<String> getDays() {
List<WebElement> elements = findElements(By.xpath(getDayXPath("")), defaultTimeout);
List<String> days = ElementUtil.getTextsFromElements(elements, true);
return days;
}
public boolean isDayVisible(final String day) {
boolean visible = isElementVisible(By.xpath(getDayXPath(getSingleDayPredicate(day))), defaultTimeout);
return visible;
}
public boolean isDayEnabled(final String day) {
boolean enabled = isElementEnabled(By.xpath(getDayXPath(getSingleDayPredicate(day))), defaultTimeout);
return enabled;
}
public void clickTodayButton() {
KeywordUtil.logInfo("Date Picker: Clicking 'Today' button");
WebElement button = findElement(By.xpath(getTodayButtonXPath()), defaultTimeout);
button.click();
}
public boolean isTodayButtonVisible() {
boolean visible = isElementVisible(By.xpath(getTodayButtonXPath()), defaultTimeout);
return visible;
}
public boolean isTodayButtonEnabled() {
boolean enabled = isElementEnabled(By.xpath(getTodayButtonXPath()), defaultTimeout);
return enabled;
}
// ***************** XPATHS *****************:
public String getPreviousMonthButtonXPath() {
return "//div[@class='react-datepicker']//button[contains(@class, 'previous')]";
}
public String getNextMonthButtonXPath() {
return "//div[@class='react-datepicker']//button[contains(@class, 'next')]";
}
public String getMonthDropdownXPath() {
return "//div[@class='react-datepicker']//div[contains(@class, 'month-read-view')]";
}
public String getMonthXPath(final String predicate) {
return "//div[@class='react-datepicker']//div[contains(@class, month-option) " + predicate + "]";
}
public String getYearDropdownXPath() {
return "//div[@class='react-datepicker']//div[contains(@class, 'year-read-view')]";
}
public String getYearXPath(final String predicate) {
return "//div[@class='react-datepicker']//div[contains(@class, year-option) " + predicate + "]";
}
public String getDayXPath(final String predicate) {
return "//div[@class='react-datepicker']//div[contains(@class, 'datepicker__week')]//div[@role='option' and not(contains(@class, 'outside-month')) " + predicate + "]"
}
public String getTodayButtonXPath() {
return "//div[@class='react-datepicker']//div[contains(@class, 'today-button')]";
}
// ***************** PREDICATES *****************:
public String getSingleMonthPredicate(final String month) {
return "and text()='" + month + "' ";
}
public String getSingleYearPredicate(final String year) {
return "and text()='" + year + "' ";
}
public String getSingleDayPredicate(final String day) {
return "and text()='" + day + "' ";
}
}
You would then call these methods as needed to manipulate the widget. For example, lets say I wanted to select the date of April 1, 2020, using the “next month” arrow to get to the month, the “year dropdown” to get to the year, and the actual calendar to select the day:
DatePicker datepicker = new Datepicker();
datepicker.clickNextMonthButton();
datepicker.setYear("2020");
datepicker.clickDay("1");