user1445967
user1445967

Reputation: 1570

Katalon Script: Find element by attributes and click it

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?

Upvotes: 1

Views: 1915

Answers (1)

Mate Mrše
Mate Mrše

Reputation: 8394

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

Upvotes: 2

Related Questions