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

Hello,

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(CustomKeywordDelegatingMetaClass.java:50)
at xxxxxxxxxxxx.run(xxxxxxxxxxxx:20)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1585480108962.run(TempTestCase1585480108962.groovy:23)

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.