1

I have some yes/no radio buttons and it would be much faster if I did not have to register these as 'test objects' using many clicks in the UI.

Is there a way to edit my test script to find these elements by-attribute and click them?

1 Answer 1

2

You don't need to use the UI (By that I presume you mean the Object Repository).

For example, if you have the following HTML:

<form action=""> <input type="radio" value="On"> On<br> <input type="radio" value="Off"> Off<br> </form> 

You can make a parametrized object in the script (and not using web spy/record feature):

def switch = ['on', 'off'] TestObject button = new TestObject().addProperty('css', ConditionType.EQUALS, 'input[value="'+switch+'"]') 

You will need to import these:

import com.kms.katalon.core.testobject.ConditionType import com.kms.katalon.core.testobject.TestObject 
Sign up to request clarification or add additional context in comments.

3 Comments

This is awesome, thank you and I am excited to try this. Is there any documentation on how to do things like this? I am not thrilled at documentation I have found, it seems to encourage heavy use of the Object Repository UI to identify and catalog test objects.
I strongly recommend you read this and especially this discussion on creating test objects in script vs using the object repository.
Thank you. I got it to work as I wanted by combining the info from your answer and the linked discussions. I really feel like this is not the intended usage for the product... and at least where my needs are concerned, that's a shame. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.