Katalon Script: Find element by attributes and click it

故事扮演 提交于 2021-02-19 07:52:07

问题


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:


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


来源:https://stackoverflow.com/questions/52302079/katalon-script-find-element-by-attributes-and-click-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!