# Is it possible to get a list of objects (web elements) using Katalon?

**URL:** <https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [August 7, 2023, 7:59pm UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596 "2023-08-07T19:59:09Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.avalos](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/david.avalos/32/22831_2.png) [@david.avalos](https://forum.katalon.com/u/david.avalos)\
**Post date:** [August 7, 2023, 7:59pm UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/1 "2023-08-07T19:59:09Z")

</div>

Hi,

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.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [August 8, 2023, 12:21am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/2 "2023-08-08T00:21:27Z")

</div>

> [@david.avalos](#):
>
> Is there a keyword I’m missing that can do this? is there a way to script something using the Katalon API?

~~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:

[https://docs.katalon.com/docs/maintain/refactor-test-objects-in-katalon-studio](https://docs.katalon.com/docs/maintain/refactor-test-objects-in-katalon-studio)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [August 8, 2023, 12:23am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/3 "2023-08-08T00:23:59Z")

</div>

Here is my solution for my personal use.

> **[\[Katalon Studio\] Object Repository Garbage Collection](https://kazurayam.github.io/ObjectRepositoryGarbageCollection/)**
>
> Tool that makes a list of unused Test Objects in Katalon Studio project

> **[GitHub - kazurayam/ObjectRepositoryGarbageCollection: Tool that makes a list...](https://github.com/kazurayam/ObjectRepositoryGarbageCollection)**
>
> Tool that makes a list of unused Test Objects in Katalon Studio project - GitHub - kazurayam/ObjectRepositoryGarbageCollection: Tool that makes a list of unused Test Objects in Katalon Studio project

…

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.

> **[Refactor test objects in Katalon Studio | Katalon Docs](https://docs.katalon.com/docs/maintain/refactor-test-objects-in-katalon-studio)**
>
> Note:

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [August 8, 2023, 1:00am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/4 "2023-08-08T01:00:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [August 8, 2023, 1:01am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/5 "2023-08-08T01:01:25Z")

</div>

> [@david.avalos](#):
>
> but I noticed the “findElements” keyword is no longer available

Where did you find it?

I believe v8.6.5 still has the keyword

[https://api-docs.katalon.com/com/kms/katalon/core/webui/keyword/WebUiBuiltInKeywords.html#findWebElements(com.kms.katalon.core.testobject.TestObject,%20int)](https://api-docs.katalon.com/com/kms/katalon/core/webui/keyword/WebUiBuiltInKeywords.html#findWebElements(com.kms.katalon.core.testobject.TestObject,%20int))

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [August 8, 2023, 1:02am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/6 "2023-08-08T01:02:41Z")

</div>

You can use Selenium WebDriver API in Katalon Studio.

[WebDriver.findElements(By)](https://www.selenium.dev/documentation/webdriver/elements/finders/#all-matching-elements)

will enable you to get a list of matching WebElements (plural).

---

<div class="post-metadata">

**Author:** ![david.avalos](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/david.avalos/32/22831_2.png) [@david.avalos](https://forum.katalon.com/u/david.avalos)\
**Post date:** [August 8, 2023, 1:15am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/7 "2023-08-08T01:15:44Z")

</div>

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.

> **[\[WebUI\] Find Web Element | Katalon Docs](https://docs.katalon.com/docs/create-tests/keywords/keyword-description-in-katalon-studio/web-ui-keywords/webui-find-web-element)**
>
> Description

> **[\[WebUI\] Find Web Elements | Katalon Docs](https://docs.katalon.com/docs/create-tests/keywords/keyword-description-in-katalon-studio/web-ui-keywords/webui-find-web-elements)**
>
> Description

I think I’m gonna end up creating a work around in selenium, something like this:

```auto
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.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [August 8, 2023, 1:54am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/8 "2023-08-08T01:54:37Z")

</div>

Nice solution.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [August 8, 2023, 5:15am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/9 "2023-08-08T05:15:05Z")

</div>

You can find the source code of `WebUI.findWebElements()` keyword at

[https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/webui/keyword/WebUiBuiltInKeywords.groovy](https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/webui/keyword/WebUiBuiltInKeywords.groovy)

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 `WebDriver.findElements(By)`).

---

<div class="post-metadata">

**Author:** ![rice](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rice/32/25535_2.png) [@rice](https://forum.katalon.com/u/rice)\
**Post date:** [April 5, 2024, 8:05am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/10 "2024-04-05T08:05:43Z")

</div>

@kazurayam - so how come WebUI.findWebElements is unable to get all elements? were infact they are having same underlying code.

Coz we are also facing same issue in WebUI.findWebElements were it cannot get the list of elements.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 5, 2024, 9:40am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/11 "2024-04-05T09:40:55Z")

</div>

@rice

> [@rice](#):
>
> so how come WebUI.findWebElements is unable to get all elements?

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.

1. your xpath could be wrong
2. your code possilbly does not wait for the page to load

---

<div class="post-metadata">

**Author:** ![rice](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rice/32/25535_2.png) [@rice](https://forum.katalon.com/u/rice)\
**Post date:** [April 5, 2024, 10:02am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/12 "2024-04-05T10:02:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [April 6, 2024, 3:12pm UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/13 "2024-04-06T15:12:48Z")

</div>

I’m not sure if all the references use the same method, but you can also use:

```auto
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebHelper

List<WebElement> list = WebHelper.findWebElements(findTestObject(...), 10)

```

---

<div class="post-metadata">

**Author:** ![rice](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/rice/32/25535_2.png) [@rice](https://forum.katalon.com/u/rice)\
**Post date:** [April 9, 2024, 1:44am UTC](https://forum.katalon.com/t/is-it-possible-to-get-a-list-of-objects-web-elements-using-katalon/93596/14 "2024-04-09T01:44:02Z")

</div>

@grylion54 thanks for this.
