Hi,

The following code which is written in Selenium is responsible for selecting a date from the Calendar:

SeleniumWebDriver webDriver = new SeleniumWebDriver(WebBrowser.GOOGLE_CHROME, true);

webDriver.openUrl(“https://some URL”);

webDriver.login(webDriver);

Thread.sleep(5000);

//Click on calendar

webDriver.clickOn(WebElementIdentifierType.ID,“headerTimeLable”);

//Navigate to the left date picker

webDriver.clickOn(WebElementIdentifierType.ID,“calenderLeftCustomDatePicker”);

//Get all td of tables using findElements method receiving XPATH as a parameter

List allDates = webDriver.findElements(“//table[1]//td”);

//using for loop to get text of all elements

for(WebElement ele:allDates) {

String date=ele.getText();

//If the date is matches “28” then click

if(date.equalsIgnoreCase(“28”)) {

ele.click();

break;

}

}

I want to accomplish the same with Katalon, but I’m unable to convert the List of WebElements into a List of TestObjects recognizable by Katalon API (the following part):

List allDates = webDriver.findElements(“//table[1]//td”);

for(WebElement ele:allDates) {

String date=ele.getText();

if(date.equalsIgnoreCase(“28”)) {

ele.click();

break;

}

}

Looking forward to hear back from you.

Kind regards,

You can call the WebDriver API directly within Test Cases of Katalon Studio. Have a look at this recent article:

Therefore you need not to convert the List of WebElements into something else.

Katalon’s built-in keywords are designed to work on a single instance of HTML element node. For example: WebUI.getText()

As far as I know, there is none published built-in keyword that returns an instance of java.util.List<org.openqa.selenium.WebElement>

I have ever developed a custom keyword which returns a List of HTML element node’s text.
https://github.com/kazurayam/KatalonDiscussion6992
However, I think I do not need it. I can call WebDriver’s API directory in Katalon Test Cases. It is most straight forward.

Thanks for a useful article.
I eventually found a simpler solution, but good to know it’s possible to use Katalon keywords with custom WebDriver instances.