I have 10 different input buttons (radio) that I want to test. I want to switch them on and off and test the results on the page.
I want to put the ids for the buttons into EXCEL. Read the ids (using a loop) and click the buttons.
As far as I can tell to do this Katalon I'll need to create test object and assign them the relevant ids and then click them.
I can do the loop, the EXCEL variables and the click but I can't create the objects and find them on the page. The bit of code is:
TestObject objecToUse = new TestObject("objectName")
objecToUse.setSelectorMethod(SelectorMethod.BASIC)
objecToUse.addProperty("id", ConditionType.EQUALS,"jform_params_show_end_time0")
WebUI.click(objecToUse)
The console output just says no such property value for calss: Script....
I could do it by having lots of code - the same for each button but I'm hoping I don't need to do that.
Update with more code and HTML
HTML code showing two of the boxes. I actually search for the for="jform_params_show_end_time0" attribute rather than id. Also you check whether the button has been pressed via the class - whether it is active or not
attributeNo = WebUI.getAttribute(findTestObject('object_path /adminEventsShowEndTimeNo'),
'class')
System.out.println(attributeNo)
if (attributeNo.contains('active')) {
System.out.println('active found in No')
WebUI.click(findTestObject(value))
}
anyway the html is
<fieldset id="jform_params_show_end_time" class="btn-group btn-group-yesno radio">
<input type="radio" id="jform_params_show_end_time0" name="jform[params][show_end_time]" value="0" checked="checked">
<label for="jform_params_show_end_time0" class="btn active btn-danger">NO </label>
<input type="radio" id="jform_params_show_end_time1" name="jform[params][show_end_time]" value="1">
<label for="jform_params_show_end_time1" class="btn">YES </label>
</fieldset>
<fieldset id="jform_params_show_end_time" class="btn-group btn-group-yesno radio">
<input type="radio" id="jform_params_show_end_time0" name="jform[params][show_end_time]" value="0" checked="checked">
<label for="jform_params_show_end_time0" class="btn active btn-danger">NO</label>
<input type="radio" id="jform_params_show_end_time1" name="jform[params][show_end_time]" value="1">
<label for="jform_params_show_end_time1" class="btn">YES</label>
</fieldset>
and I tried
TestObject objecToUse = new TestObject("objectName")
objecToUse.setSelectorMethod(SelectorMethod.BASIC)
objecToUse.addProperty("for", ConditionType.EQUALS,"jform_params_show_end_time0")
WebUI.click(objecToUse)
which crashes ( my intention is to swap jform_params_show_end_time0 for a variable pulled from the excel spreadsheet)