Recently I found a scenario where detecting multiple objects would come in handy but I noticed the “findElements” keyword is no longer available and the API documentation states that TestObject.findTestObject() will retrieve only one object. I’d like to have a list of objects retrieved so I can manipulate and perform validations on the test objects. Is there a keyword I’m missing that can do this? is there a way to script something using the Katalon API?
I figure I can just create a custom keyword using selenium and move forward but I wanna make sure I’m not skipping a Katalon based solution which would be better for my purpose.
Thanks in advance.
Unfortunately and surprisingly enough, no. Katalon does not provide a wayt to get a list of Test Objects in the Object Repository directory.
This page may suggest something to you:
Here is my solution for my personal use.
I found this project is poorly documented.
It contains several useful (I believe) functionalities, but they are not documented at all.
Forgive me, this is for my own use.
Now I remember, I abandoned this project in March 2023 because I found Katalon Studio equips a feature of finding garbage Test Objects. The following doc explains their feature.
I realized my misunderstanding. You want to get a list of web elements in a page; you do not want to get a list of Test Objects in a Object Repository directory.
You can use Selenium WebDriver API in Katalon Studio.
will enable you to get a list of matching WebElements (plural).
Yes, I do want to get a list of web elements.
I remember using findElements years ago but when looking through the built-in keyword I couldn’t find it anymore. I figure maybe it was replaced with something else, but apparently no. Also you can still find it in the documentation.
I think I’m gonna end up creating a work around in selenium, something like this:
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.By as By
import org.openqa.selenium.WebElement as WebElement
import java.util.List as List
WebDriver driver = DriverFactory.getWebDriver()
xpath = findTestObject('Common/span_activeBlendAllocationList').getSelectorCollection().get(SelectorMethod.XPATH)
List<WebElement> elements = driver.findElements(By.xpath(xpath))
//to do validations
I appreciate the help and the code you shared.
You can find the source code of
WebUI.findElements() keyword at
see Line 2860.
You can dig the source in detail. Ultimately you would find that the
WebUI.findWebElements keyword does the same as what your code above does (call