Katalon Recorder Get Element Count

Looking for some help on getting the element count when the script was recorded. I’m not a Katalon newbie, but I’ve been putting off all test scripts that couldn’t be done strictly with the recorder for a while so this is my first time posting. I’m not sure how it works to combine recorded steps with manual. The “eleCount” part of the script is just something I tried from a post I read.

‘Verify Task Displays on the Page’
WebUI.verifyElementText(findTestObject(‘Object Repository/Page_Tasks/a_Automated Test - Recurring Task’), ‘Automated Test - Recurring Task’)

‘Verify task displays selected number of times’
def eleCount = driver.findElements(
By.class(“task-details”)).size()

This is the html I’m trying to verify displays a specific number of times
Automated Test - Recurring Task

Please let me know if you need more details. Thank you

Firstly, “Katalon Recorder” is an entirely different product to Katalon Studio. You’re using the KS Record Web feature, not KR.

It seems you tried to link to something called “Automated Test - Recurring Task” - unfortunately, it doesn’t link to anything.

Aside from that, your code seems to look okay, assuming you have at least one HTML element with class=task-details.

What is the issue? Is there an error reported?

Yes, I am using the recorder in Katalon Studio. Sorry, I copied the html and it didn’t look like that while I was typing.
This is the html

The error I get is
Script1623691686823.groovy: 71: Invalid variable name. Must start with a letter but was: “task
. At [71:10] @ line 71, column 10.
By.class(“task-details”)).size()

Read this and respond accordingly:

Hi. I was able to figure this out. I copied the code from another source and the quotes didn’t convert properly. Fixed the quotes and I’m no longer seeing the error. Thanks

1 Like