Error when handle Web Tables

Hello, i new in katalon studio, this is my skenario

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement

import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI


String ExpectedValue = ‘31824174271065917763’

WebDriver driver = DriverFactory.getWebDriver()

WebElement Table = driver.findElement(By.xpath(’//[@id=“kt_content”]/div[2]/div/div[1]/div[2]/div[1]/table/tbody’))

List Rows = Table.findElements(By.tagName(‘tr’))


table: for (int i = 0; i < Rows.size(); i++) {


List<WebElement> Cols = Rows.get(i).findElements(By.tagName('td'))

for (int j = 0; j < Cols.size(); j++) {
	println (Cols.get(j).getText())
	if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {



And then this is error

java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
at java_util_List$get$ Source)
at Create Adjustment Adjustment Reconcile:50)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
at com.kms.katalon.core.main.TestCaseExecutor.runScript(
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(
at com.kms.katalon.core.main.TestCaseExecutor.execute(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)

this code can find my expected value (31824174271065917763) but can’t click button. Error in this code

And this is my html code, i want to click

360001FE902542081916 36020200836000100 KREDIT ALREADY ADJUSTED **** Stockholm-icons / Communication / WriteCreated with Sketch.

Please help me, thank you

@nurprasetyo.kurniawa You do not need the findElement bit. Shorten the statement to:


This assumes you want to click on the link from the sixth column. Is that correct? If you want the link from the fifth column, then you should use the index 4. The array is zero based. So zero is the first column, 1 would be the second, etc.

If the link is in the last position, then you might use the array index as: Cols.size() - 1

1 Like

Let’s take above HTML table as an example:

WebElement htmltable=driver.findElement(By.xpath("//*[@id=‘main’]/table[1]/tbody"));
List rows=htmltable.findElements(By.tagName(“tr”));

for(int rnum=0;rnum<rows.size();rnum++)
List columns=rows.get(rnum).findElements(By.tagName(“th”));
System.out.println(“Number of columns:”+columns.size());

for(int cnum=0;cnum<columns.size();cnum++)
Step 1: First get the entire HTML table and store this in a variable ‘htmltable’ of type web element.

Step 2: Get all the rows with tag name ‘tr’ and store all the elements in a list of web elements. Now all the elements with tag ‘tr’ are stored in ‘rows’ list.

Step 3: Loop through each row and get the list of elements with tag ‘th’. ‘rows.get(0)’ will give first row and ‘findElements(By.tagName(“th”))’ will give list of columns for the row.

Step 4: Iterate using ‘columns.getsize()’ and get the details of each cell.

Note: Above approach will be best suitable if the table dimensions changes dynamically.

This concludes the topic how to handle web tables in selenium. Next, we will learn about handling an element inside a frame.

Thanks alot @grylion54
problem solved