18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Loop through elements - checkbox
Hi All,
I have found the following code very useful, thought i'd share it.
I had a bit of difficulty previously when trying to loop through form elements.
The following code is for looping through checkbox elements in a form, although it could be altered to loop through any document element:
Enjoy!
(SAHI V3.5, Firefox4, Windows7)
Josh
I have found the following code very useful, thought i'd share it.
I had a bit of difficulty previously when trying to loop through form elements.
The following code is for looping through checkbox elements in a form, although it could be altered to loop through any document element:
<browser>
function getAnyChecked($form){
for (var $i = 0; $i < $form.elements.length; $i++) {
if ($form.elements[$i].type == 'checkbox') {
if ($form.elements[$i].checked == true) {
return true;
}
}
}
return false;
}
</browser>
Usage:
_assertNotTrue(getAnyChecked(document.forms[0]));
Enjoy!
(SAHI V3.5, Firefox4, Windows7)
Josh