How can I search text in grid and how to define a grid


Is there a way to search element and text in grid?
What is the syntax?

I have created an object of that grid but it doesn’t seem to work, by using the following:

TestObject aMotanescu = new TestObject(“Object Repository/Grid”)

Thank you

Yes, but we need to see the HTML you are dealing with. Please follow this advice:

So I have tried with contains but I have found lately that contains only supports boolean, nothing from the condition package seems to fit what I am looking for.

I get the " Cannot cast object" error followed by →

Mar 23 2020 4:37:00 PM’ with class ‘java.lang.String’ to class ‘com.kms.katalon.core.testobject.TestObject’
at contracts.valueCheck.templateCheck(valueCheck.groovy:34)
at contracts.valueCheck.invokeMethod(valueCheck.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(
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)

You don’t need to use new TestObject here.
You can try

if(WebUI.getText(findTestObject('Object Repository/Grid')).contains(expectedValue)){

But if it’s doesn’t works :

Thank you for the reply. I have added the HTML

if(WebUI.getText(findTestObject('Object Repository/Grid')) == "Delia") {
 println("Found Delia")
} else {
 println("Delia NOT found")

I have tried both scenarios but it still doesn’t work :frowning:
It has a problem with my object Grid (Unable to click on object), the thing is the Grid object it is an object that contains the //tbody[@class], which isn’t a clickable object, but a list/grid which will display multiple created objects with different elements: a contextual menu, clickable text and some other text added which displays the created date.

I suspect your Object Repository/Grid object is broken.

Take another screenshot. Make sure it shows the text you are trying to verify. Make sure it shows enough HTML for me to build a locator/selector.

Instead of using the Grids XPath, you search the grid without it?

In this case, append the class statement to the table to get the specific grid. Also, remember the table columns starts at zero.