Custom Keyword: get contents of HTML elements as a list of strings

I have found that we do not need a custom keyword. A built-in keyword WebUI.findWebElements(TestObject) is available. You can write this

import org.openqa.selenium.WebElement
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.testobject.ConditionType

...
// grasp <tr> elements
List<WebElement> trElements = WebUI.findWebElements(
	new TestObject().addProperty("xpath", ConditionType.EQUALS, 
							"//div[@id='resultDiv']/table/tbody/tr"), 10)
println "trElements.size()=${trElements.size()}"

See

for working example.

2 Likes