Click on specific item in list/table

I am very new to Katalon and would like for the test case to click on a specific item in a list/table on the current page based on the text the table cell contains.

Katalon can do that but what we need from you is lot more information. Read this post to get some ideas:

Please limit your topic to one question. Post this as a new topic. Thanks!

I found the following when googling but have no idea if this is what I need:

import org.openqa.selenium.By as By
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

‘Expected value from Table’
String ExpectedValue = ‘545164320’
WebDriver driver = DriverFactory.getWebDriver()
‘To locate table’
WebElement Table = driver.findElement(By.xpath(’//table/tbody’))
'To locate rows of table it will Capture all the rows available in the table ’
List < WebElement > Rows = Table.findElements(By.tagName(‘tr’))
println('No. of rows: ’ + Rows.size())
‘Find a matching text in a table and performing action’
‘Loop will execute for all the rows of the table’
table: for (int i = 0; i < Rows.size(); i++) {
‘To locate columns(cells) of that specific row’
List < WebElement > Cols = Rows.get(i).findElements(By.tagName(‘td’))
for (int j = 0; j < Cols.size(); j++) {
‘Verifying the expected text in the each cell’
if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {
‘To locate anchor in the expected value matched row to perform action’
table: break

These are my errors. It is failing at
2019-10-14 15:40:45.527 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 60: driver = getWebDriver()
2019-10-14 15:40:45.529 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 61: Table = driver.findElement(By.xpath("//table/tbody"))
2019-10-14 15:40:45.555 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 62: Rows = Table.findElements(By.tagName(“tr”))
2019-10-14 15:40:45.630 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 63: println("No. of rows: " + Rows.size())
No. of rows: 10
2019-10-14 15:40:45.645 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 64: “Find a matching text in a table and performing action”
2019-10-14 15:40:45.645 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 65: for ([i = 0, i < Rows.size(), (i++)])
2019-10-14 15:40:45.646 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 1: Cols = get(i).findElements(By.tagName(“td”))
2019-10-14 15:40:45.661 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 2: for ([j = 0, j < Cols.size(), (j++)])
2019-10-14 15:40:45.662 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 1: if (getText().equalsIgnoreCase(ExpectedValue))
2019-10-14 15:40:45.676 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 1: if (getText().equalsIgnoreCase(ExpectedValue))
2019-10-14 15:40:45.688 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 1: if (getText().equalsIgnoreCase(ExpectedValue))
2019-10-14 15:40:45.704 DEBUG testcase.DE2001 - Add DE2 Outbound Bill - 1: tagName(“a”)).click()
2019-10-14 15:40:45.737 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/DE2/DE2001 - Add DE2 Outbound Bill FAILED.
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“css selector”,“selector”:“a”}
(Session info: chrome=76.0.3809.132)
For documentation on this error, please visit:
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘HKYNCTIINF20L’, ip: ‘’, ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 76.0.3809.132, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce…, userDataDir: C:\Users\MLilly\AppData\Loc…}, goog:chromeOptions: {debuggerAddress: localhost:64496}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: bc8bf6f9346b5e6ad3eb10bc88b3e99c
*** Element info: {Using=tag name, value=a}
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(
at org.openqa.selenium.remote.HttpCommandExecutor.execute(
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(
at org.openqa.selenium.remote.RemoteWebDriver.execute(
at com.kms.katalon.selenium.driver.CChromeDriver.execute(
at org.openqa.selenium.remote.RemoteWebElement.execute(
at org.openqa.selenium.remote.RemoteWebElement.findElement(
at org.openqa.selenium.remote.RemoteWebElement.findElementByTagName(
at org.openqa.selenium.By$ByTagName.findElement(
at org.openqa.selenium.remote.RemoteWebElement.findElement(
at org.openqa.selenium.WebElement$findElement$ Source)
at DE2001 - Add DE2 Outbound - Add DE2 Outbound Bill:157)
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)

No, it doesn’t seem to be the code you need, but let’s see if we can move it in the right direction.

It looks as though the test gets to this line:

if (Cols.get(j).getText().equalsIgnoreCase(ExpectedValue)) {

then fails on this line:


There are two things I think might be wrong.

  1. The error is correct. You are trying to access an a-element which does not exist. You have a td-element which contains the expected text, not an a-element.

  2. The code you found seems to want to match on the first cell it finds containing the expected text but THEN tries to click on the a-element in cell(4). Since you highlighted a cell in the third column, I’m guessing you want a different cell with an a-element - but I can’t say which one because I can’t see it from your screenshot.

Regarding this:

Please understand, I can’t teach you testing or programming. All I can do is give you pointers toward things you can use and develop yourself.

Also, please understand we are working blind here. You have all the resources and our help is as limited as the help you provide us to understand your problem. If your problem is your lack of knowledge about Katalon/Testing/Programming, you should put in the time to study.

Start here: