# Custom Keyword: get contents of HTML elements as a list of strings

**URL:** <https://forum.katalon.com/t/custom-keyword-get-contents-of-html-elements-as-a-list-of-strings/11137>\
**Category:** Web Testing\
**Tags:** tips-tricks, katalon-studio\
**Created:** [May 24, 2018, 7:50am UTC](https://forum.katalon.com/t/custom-keyword-get-contents-of-html-elements-as-a-list-of-strings/11137 "2018-05-24T07:50:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [January 18, 2019, 10:12am UTC](https://forum.katalon.com/t/custom-keyword-get-contents-of-html-elements-as-a-list-of-strings/11137/2 "2019-01-18T10:12:26Z")

</div>

I have found that we do not need a custom keyword. A built-in keyword `WebUI.findWebElements(TestObject)` is available. You can write this

```auto
import org.openqa.selenium.WebElement
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.testobject.ConditionType

...
// grasp <tr> elements
List<WebElement> trElements = WebUI.findWebElements(
	new TestObject().addProperty("xpath", ConditionType.EQUALS, 
							"//div[@id='resultDiv']/table/tbody/tr"), 10)
println "trElements.size()=${trElements.size()}"

```

See

> [@Chrome: saving an xml file instead of displaying it](http://forum.katalon.com/t/chrome-saving-an-xml-file-instead-of-displaying-it/15677/21):
>
> I extended my demo project further. See [GitHub - kazurayam/SavingAnXmlFileRatherThanDisplayingIt: Visit a web page, where I identify a href to RSS document; send GET request for the document and save it into local file; do all in a Katalon Test case](https://github.com/kazurayam/SavingAnXmlFileRatherThanDisplayingIt/) The Application Under Test [Sample](https://kazurayam.github.io/SavingAnXmlFileRatherThanDisplayingIt/) now has 3 rows: Please note: The 1st row contains 1 link to XML. The 2nd row contains no link to XML. The 3rd row contains 2 links to XML files. I added a Test Case [TC3](https://github.com/kazurayam/SavingAnXmlFileRatherThanDisplayingIt/blob/master/Scripts/TC3/Script1546641047357.groovy). This test case scans the target HT…

for working example.

---

_[View the full topic](https://forum.katalon.com/t/custom-keyword-get-contents-of-html-elements-as-a-list-of-strings/11137)._
