How to find an exact name in a specific column through pagination in a web table?

Hello, I want to look for a specific name starting with the letter ‘B’ in the 3rd col. only. Once it gets the expected name, the loop stops. Then it captures the name with its EMP ID and *clicking on the checkbox.

There are many pages. In a page, there are 15 rows per page with different data.

Some Screenshots:




Errors:



Part of the code is as follows:

def TrimName=GlobalVariable.Value.substring(0,1)
println(TrimName) // In our case it is ‘B’

def alphabet_B=WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Reported By/Filter’), ‘text’, ‘equals’, TrimName, false)

WebUI.click(alphabet_B)

WebUI.delay(5)
int Counter=0
def CheckName=true

while(CheckName) {
Counter=Counter+1
if (Counter<50) {

correctName=WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Reported By/ApplicationAccount2 - Copy’), ‘text’, ‘equals’, ExactName, true)

if (WebUI.waitForElementVisible((correctName),3)) {
CheckName=true
break
}

	else {
		WebUI.click(findTestObject('Object Repository/Reported By/Next'))
		WebUI.delay(2)
	}
	}


else {
	CheckName=false
	println "Name is not present in the directory"
	break
}

}

Can you very humbly help me? If you have another logic, please do share it here.

Please use Code Formatting syntax for better readability of your codes.

You have not stated any question yet. What is your question? Please do not let others guess what your question is.

The screenshot shows a few error messages. Therefore your code must have some problems. But you haven’t explained what you have done to fix the errors. It seems you do not mind them at all. It seems you haven’t done any study about the errors yet. I wonder what you want others to do.

If you want to be answered, you should clearly ask questions.

Hello, it’s just been 7 days I started using Katalon for automation. I am still on the learning and research phase. I am studying every aspect on it little by little.

My question is: How can we find a specific name for eg “Ben Issa” on the 3rd column if it is on the 12th page?
Once it gets the expected name, how to capture it with its EMP ID?

I am still working to fix the errors you know. But some object locators work well when you inspect them in developer mode but same are used in Katalon, there are errors.

The codes:

def TrimName=GlobalVariable.Value.substring(0,1)
println(TrimName) // In our case it is ‘B’

def alphabet_B=WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Reported By/Filter’), ‘text’, ‘equals’, TrimName, false)
WebUI.click(alphabet_B)

WebUI.delay(5)
int Counter=0
def CheckName=true

while(CheckName) {
Counter=Counter+1

if (Counter<50) {
correctName=WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Reported By/ApplicationAccount2 - Copy’), ‘text’, ‘equals’, ExactName, true)

if (WebUI.waitForElementVisible((correctName),3)) {
CheckName=true
break
}

else {
	WebUI.click(findTestObject('Object Repository/Reported By/Next'))
	WebUI.delay(2)
}
}


else {
	CheckName=false
	println "Name is not present in the directory"
	break
}
}

Thanks.

Please have a look at the following guidance before posting the next:


This is not enough.

Please show us the error messages. You can see the errors, but others can not. You should explain what the error message you got.

The error message would indicate which line of the test case script is causing the error. The line# of script wehre Error occured, with message from the system “”.

Then you should tell others which line of code is problematic. You should make best effor why you got that error, and ask questions about it specifically. Do not say just “please help me”.

Hello @kazurayam, thanks a lot for all the guidance. I really appreciate.

I modified the code as seen below. I have change the xpath. The correct name is in the 13th row but the loop continues.

WebUI.click(findTestObject('Reported By/letterB'))

WebUI.delay(3)

int Counter = 0

def CheckName = true

while (CheckName) {
  
    Counter = (Counter + 1)

    if (Counter < 50) {
        println(Counter)

        correctName = WebUI.modifyObjectProperty(findTestObject('Object Repository/Reported By/ApplicationAccount2'), 'xpath', 
            'equals', '//table[@class="MN mlist_tbl"]/tbody/tr/td[3]', false)
		
        if (WebUI.waitForElementVisible(correctName, 3)) {
            CheckName = true
            break
        } 
		else {
            WebUI.click(findTestObject('Object Repository/Reported By/Next'))

            WebUI.delay(2)
        }
        
    } else {
        CheckName = false

        println('Name is not present in the directory')

        break
    }
}

HTML screenshot:

Results from console



I cannot upload the error log because it is not authorized. Though, I have provided all the essential information.

@1Medy_Albion

Thank you for the information provided.

However still you have stated NO QUESTION yet. You should not expect others would kindly & correctly guess your question.

What is your question?


This seems suggesting that you expected the loop stops at some stage, but it continues. You can not find the reason why the loop does not stop.

Am I right?

I have never used WebUI.modifyObjectProperty() keyword. I was not aware of this keyword at all up until now. I have never seen any post in this forum where somebody using this.

Still I could find in the Katalon document site

And I could find its source code

You are wondering why the loop in your script does not stop. — Perhaps you are using WebUI.modifyTestObject() keyword wrongly.

Especially, you specified false to the 5th argument. Are you sure? Is false appropriate?

As I wrote, I have never used this keyword. So I do not know what. Please check it yourself.

I read the document https://docs.katalon.com/katalon-studio/docs/webui-modify-object-property.html#parameters and found a section:

What?
Very puzzling.
I do not understand this description at all.

Anyway, the isActive is of Boolean type. It has only 2 possible values: true and false. It’s easy for @1Medy_Albion to try both.

Hello @kazurayam. Yes, you are absolutely right! The loop must stop at some point when it has the exact name.

Question: Why the loop does not stop? Perhaps I have wrongly use WebUI.modifyTestObject().

Thanks a lot mate! I am further investigating on the function WebUI.modifyTestObject().

If you want your loop to stop, then I think you have this incorrect. To stop your “while” loop, you
need to make your loop condition become false, so you want:

if (WebUI.waitForElementVisible(correctName, 3)) { 
    CheckName = false
    break;        // and you really don't need this
}

I also have never used modifyObjectProperty, so good show if it works.