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.
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.
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
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 WebDriver.findElements(By)).
I have no idea. You haven’t explained your case to others. You haven’t showed your code. You haven’t shared your target URL and HTML source. The guys in the forum can not guess what’s happening to you without sufficient information disclosed.
I just guess that there is nothing wrong in the keyword implementation.
Possibly your code has something that gets you puzzled.
your xpath could be wrong
your code possilbly does not wait for the page to load
sorry for puzzling you… I was referring my reply from the thread issue in this topic. So the context revolves to the findWebElements if it has issue in determining test object.
I’m not sure if all the references use the same method, but you can also use:
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebHelper
List<WebElement> list = WebHelper.findWebElements(findTestObject(...), 10)