Using variable in Object's Properties


#21

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
Thanks


#22

@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


#23

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


#24

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.

Thanks,

Chris


#25

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.


#26

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)


#27

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

https://docs.katalon.com/pages/viewpage.action?pageId=12419075


#28

@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.


#29

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


#30

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