Mike Warren
Mike Warren

Reputation: 3886

Getting a list of elements contained in a ul TestObject in Katalon

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

Answers (2)

Kate Hua
Kate Hua

Reputation: 51

  1. Assumed that your Test Object(named: listItem) has the XPath like below :

    //*[@id="myUlElement"]/li

  2. 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

Mike Warren
Mike Warren

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

Related Questions