How does one Click on the latest option in a table grid?

Hi all

So I am very new to Katalon. Let me try and explain the best I can.

On one tab I perform an action which results in a response in another part of the site. I change tabs and navigate to the page which lists the responses by latest.

The issue that I am currently facing, is that when recording, I click on the latest response in the table grid which creates a pop up where I can get further information. This however creates an Object Repository for only the response that I clicked e.g.

WebUI.click(findTestObject(‘Object Repository/Page_Inscape Connect - Communication Detail/td_Dear FirstName SurnameI am pleased to se_a03272’))

When I run the test case again, instead of selecting the most recent response (which I actually need) it will select the Object that I showed above (ending in a03272)

Is there a way to rather look for the most recent on the table grid and always click the most recent?

EDIT FOR CLARIFICATION:

I have added the following code. As you will see, I go through an Enrolment, and to give context, on the other window I need to get the OTP that is generated for the Enrolment.

This is the problem. When I switch to the other window and navigate to the correct place, I am presented with a table grid which is clickable to generate a popup. Now when I did this in the recorded, it recorded the specific row in the table grid, however I want to click on the most recent row in the table grid. Does this info help more?

WebUI.switchToWindowIndex(currentTab + 1)

WebUI.navigateToUrl('https://inscape-operations-staging.stratusolvecloud.com/App/Student/Workflow/NewEnrolment/2022')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Welcome to INCONNECT - our online stu_0eecac'), 
    'Testing')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Welcome to INCONNECT - our online stu_d2ddfb'), 
    'Katalon')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_land Islands_cell'), 
    '0426379462')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Valid_c3'), 'hsfhsfdgh@dfgdg.com')

WebUI.selectOptionByValue(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/select_Country of OriginSouth AfricaUnited _72b9c5'), 
    '1', true)

WebUI.selectOptionByValue(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/select_--Select ID Type--RSA ID NumberPassp_e4a2f7'), 
    '2', true)

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Valid_c7'), 'kattest1!')

WebUI.setEncryptedText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Valid_c4'), 
    'p4y+y39Ir5PEPmX20UxFKw==')

WebUI.setEncryptedText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_A digit (0-9) is required_c5'), 
    'p4y+y39Ir5PEPmX20UxFKw==')

WebUI.click(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_land Islands_cell'))

WebUI.click(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/button_Next'))

WebUI.switchToWindowIndex(currentTab + 0)

WebUI.click(findTestObject('Object Repository/Page_Connect - Members - Individual Overview/a_Communication'))

WebUI.click(findTestObject('Object Repository/Page_Connect - Members - Individual Overview/a_Triggered Communications'))

WebUI.click(findTestObject('Object Repository/Page_Inscape Connect - Triggered Communications/td_Email Verification'))

WebUI.click(findTestObject('Object Repository/Page_Inscape Connect - Communication Detail/a_Message Recipients'))

WebUI.click(findTestObject('Object Repository/Page_Inscape Connect - Communication Detail/td_Dear FirstName SurnameI am pleased to se_a03272'))

WebUI.delay(5)

WebUI.closeWindowIndex(currentTab + 2)

I have attached two screenshots. Does this help?

So as you see, these are clickable “rows” in a table that cause a popup tab, and there are many. The second screenshot shows the next row below it.

Each row has its own “ID” so to speak, so currently when my test case runs, it just looks for the specific row that I clicked on in the recording, but I need to click on the most recent row everytime (the top one)

Welcome to the forum.

Yes, please. Take a look at the following and post anything you think is appropriate (rarely is too much info a problem).

1 Like

No problem. I have added the following code. As you will see, I go through an Enrolment, and to give context, on the other window I need to get the OTP that is generated for the Enrolment.

This is the problem. When I switch to the other window and navigate to the correct place, I am presented with a table grid which is clickable to generate a popup. Now when I did this in the recorded, it recorded the specific row in the table grid, however I want to click on the most recent row in the table grid. Does this info help more?

WebUI.switchToWindowIndex(currentTab + 1)

WebUI.navigateToUrl('https://inscape-operations-staging.stratusolvecloud.com/App/Student/Workflow/NewEnrolment/2022')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Welcome to INCONNECT - our online stu_0eecac'), 
    'Testing')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Welcome to INCONNECT - our online stu_d2ddfb'), 
    'Katalon')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_land Islands_cell'), 
    '0426379462')

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Valid_c3'), 'hsfhsfdgh@dfgdg.com')

WebUI.selectOptionByValue(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/select_Country of OriginSouth AfricaUnited _72b9c5'), 
    '1', true)

WebUI.selectOptionByValue(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/select_--Select ID Type--RSA ID NumberPassp_e4a2f7'), 
    '2', true)

WebUI.setText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Valid_c7'), 'kattest1!')

WebUI.setEncryptedText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_Valid_c4'), 
    'p4y+y39Ir5PEPmX20UxFKw==')

WebUI.setEncryptedText(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_A digit (0-9) is required_c5'), 
    'p4y+y39Ir5PEPmX20UxFKw==')

WebUI.click(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/input_land Islands_cell'))

WebUI.click(findTestObject('Object Repository/Page_Connect - Operations - Student Enrolment/button_Next'))

WebUI.switchToWindowIndex(currentTab + 0)

WebUI.click(findTestObject('Object Repository/Page_Connect - Members - Individual Overview/a_Communication'))

WebUI.click(findTestObject('Object Repository/Page_Connect - Members - Individual Overview/a_Triggered Communications'))

WebUI.click(findTestObject('Object Repository/Page_Inscape Connect - Triggered Communications/td_Email Verification'))

WebUI.click(findTestObject('Object Repository/Page_Inscape Connect - Communication Detail/a_Message Recipients'))

WebUI.click(findTestObject('Object Repository/Page_Inscape Connect - Communication Detail/td_Dear FirstName SurnameI am pleased to se_a03272'))

WebUI.delay(5)

WebUI.closeWindowIndex(currentTab + 2)

Define “most recent” – keep in mind I can’t see it. A screenshot would help. And a screenshot of the HTML in DevTools.

1 Like

No problem, I have attached two screenshots. Does this help?

So as you see, these are clickable “rows” in a table that cause a popup tab, and there are many. The second screenshot shows the next row below it.

Each row has its own “ID” so to speak, so currently when my test case runs, it just looks for the specific row that I clicked on in the recording, but I need to click on the most recent row everytime (the top one)

You will have to fill in what may come below the <td> you have highlighted that you need to click on, however, the below may be one way you could do it. This makes a TestObject in code, however, you could just make a new Test Object in the OR and give it the xpath below.

import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI


"xpath to the first row, fourth column"
xpath = '//table/tbody/tr[1]/td[4]'
"make a test object in code"
TestObject tObj = new TestObject(xpath)
tObj.addProperty("xpath", ConditionType.EQUALS, xpath)
"click on the newest row"
WebUI.click(tObj)
If pathway not unique:

If the above pathway is not unique, then we have to add to make it unique:

id("MessageDataGrid-grid")/div[2]/table/tbody/tr[1]/td[4]

Edit: I started thinking if the pathway for the first element of the table you got using Web Spy is the same as what I have above, then you may only change the name of the element to something more generic and perhaps remove any attributes that are too specific for the table’s first element.

Thank you! This last part fixed my issue! Now on to my next problem. I need to essentially read through a page to copy and paste a specific piece of the page