Reputation: 3886
I have saved a TestObject in Katalon, which has a ul tag. I wish to use that to write a test case that involves its li elements, but don't know how to select, let alone loop through, them in Katalon. In Selenium WebDriver, it would be something like driver.findElements(By.css("#myUlElement li"))
followed by something like an enhanced for loop.
How to do this in Katalon?
Upvotes: 3
Views: 8539
Reputation: 51
Assumed that your Test Object(named: listItem) has the XPath like below :
//*[@id="myUlElement"]/li
On your test case/ keyword, to get the list of li web element, use below:
List<WebElement> listElement = WebUI.findWebElements(findTestObject("listItem"),2)
See more about findWebElements here.
Hope this helps!
Upvotes: 5
Reputation: 3886
I stumbled upon the answer. I found out you could bring in the WebDriver
like this: WebDriver driver = DriverFactory.getDriver()
. That would allow for Selenium-specific code within Katalon script
Upvotes: 1