Using variable in Object's Properties

kazurayam said:

Your code can be rewritten as follows.

WebUI.verifyElementPresent(    findTestObject(        findTestObject(            'Favourite Documents/Page_Documents List/Test',            [('docTitle') : DocTitle])    ),    50)

Don’t you find nested findTestObject() calls here?

Hi yes
Sorry I copied findTestObject by mistake

@Usha_J, was your issue resolved. bumping into the same thing and I can’t wrap my head around it. Tried the above with both css and xpath and I’m running into an unresolved variable each time.

Kind regards

@matthias.dirickx Did you ever get an answer to your question or resolve your issue?

Hi @sgiebner and @matthias.dirickx,

If you’re still having issues, could you please restate the problem you’re trying to solve and share what you’ve tried? There was a lot of back and forth previously and it got a bit confusing.



1 Like

Basically I have tried this:

But that did not work out.

What I am doing now as a workaround is basically overriding the method.

There’s a TestObjectSupport class with static methods. One of them resolves a variable (no nested values, just plain simple) I must admin I did not try it again. I’m working on the project again now, so I’ll get back to it. THanks for the mail follow-up by the way!

As for the code: instead of using the piece above I did:

 * (!) Nested varriables / properties are not supported. It may work in some occasions, but it should not be done.
 * @param to -- TestObject, the test object to modify
 * @param props -- Map<String, String>, set of properties.
 *                 Key is property name, value is the value it will be replaced with.
 *     --> The properties are replaced when they are marked like "${propertyHere}".
 * @return TestObject - The modified TestObject object
public static TestObject resolveActivePathForTestObject(TestObject testObject, Map<String, String> props) {
	String resolvedSelector = getActiveSelectorString(testObject)

	props.each {key, value ->
		resolvedSelector = resolvedSelector.replaceAll('\\$\\{' + key + '\\}', value)

	testObject.setSelectorValue(testObject.getSelectorMethod(), resolvedSelector)

	return testObject

Using the builltin method would be the way to go of course… But again, did not try it since I just started out with POC-ing Katalon.

Hi Chris,

In WebUI, trying to use a variable in object properties just as Testernik_Testowy was trying to do in Mobile.

Basically, for WebUI trying to reproduce this Mobile code from Testernik_Testowy on Jun '18 above;
Mobile.selectListItemByLabel(findTestObject(‘TEST1/LIST_SELECTION’), randomNumber, 10)

Can this link be restored?
I just get a “No Such Link” error.

1 Like

@Chris_Trevarthen fyi, I figured this out, so nothing needs to be done.
Bringing back the link in the below would be nice for other users though.

Ive tried with this three types and doesnt work. Im not coder so i dont work much with scripting view…

Doesnt detect the object

Help please

Hi @pgonzalez,

Here are some Katalon docs on how to parameterize a test object. It’s a mix of the Manual and Script views, but it’s pretty good at walking you through it. Please let me know if you need some additional info:

– Chris

I did what the docu shows ‘Using the variable for the value of the dynamic property’, and I get result ‘Not Found’ ,

here is the log: Caused by: com.kms.katalon.core.exception.StepFailedException: Element ‘Object Repository/Roles/Role_Audit/Audit_Date’ not found

What i did is this:

Katalon v. 6.3.3

So , am I doing somthing wrong? can you guide me?. Thanks.

Hi @pgonzalez,

In your script, could you try changing the AuditDate variable to the text you want to use, 10 - October - 2019? This could help narrow down if it’s a problem getting the variable into the script or whether it’s a problem getting the parameter into the test object.

So it would look like:

Mobile.verifyElementExist(findTestObject('Roles/Role_Audit/Audit_Date', [('text') : '10 - October - 2019']), 0)

Hope this helps,


1 Like

it worked changing variable to text

and changing the object view, left the text attribute in blank

Thanks so much.

1 Like

@Chris_Trevarthen But why doesnt work with a variable? will be this available in the future ? its very useful if it works with a variable.

@pgonzalez as far as i remember, for the rest-api objects, when you do data binding from the tescase (call the object with parameters) you have to pass all parameters declared in object variable tab with a certain value.
otherwise the ones not binded will be ‘emptied’ even it in the object repository they have a value (which imho should be treated as a default)
i think there is a bug report opened on this matter.
could be the case that web objects behave the same …

Hi @pgonzalez,

Glad it’s working when passing in the value directly.

The next thing to check is if your test script is pulling in the variable correctly. If you’re using Test Case Variables, then you’ll need to wrap the variable in ${} when you use it in your script:

Mobile.verifyElementExist(findTestObject('Roles/Role_Audit/Audit_Date', [('text') : '${AuditDate}']), 0)

Hope this helps,


Hi guys, Tried again pulling in the variable:
The code i’m trying to test with this feature (using variable in object properties)

Mobile.verifyElementExist(findTestObject(‘Roles/Role_Audit/Audit_Date’, [(‘text’) : ‘${AuditDate}’]), 0)
tempvar = Mobile.getText(findTestObject(‘Roles/Role_Audit/Audit_Date’, [(‘text’) : ‘${AuditDate}’]), 0)

It marks it as PASS but doesn’t print the value from the object with variable in the text property:

The object:

The variable:

If I enter ‘${AuditDate}’ or ${AuditDate} (tried with both) in attribute text inside the object, the result is
Element not found.

Hi @pgonzalez,

I noticed from your last screenshots that the “Audit_Date” Test Object doesn’t have any of the “Detect object by” checkboxes selected. If you’re running your test that way, can you try selecting the class property as a minimum?

– Chris

change it to:

Mobile.verifyElementExist(findTestObject(‘Roles/Role_Audit/Audit_Date’, [(‘text’) : AuditDate]), 0)

and same for the next line

Have a look at the “string interpolation” section of the Groovy language syntax tutorial.

By Groovy language syntax rule, a string with interpolated expression ${AuditDate} must be quoted by double quotations.

    ['text' : "${AuditDate}"]), 0)
tempvar = Mobile.getText(findTestObject('Roles/Role_Audit/Audit_Date',
    ['text' : "${AuditDate}"]), 0)