Micro Focus QTP (UFT) Forums
How to select multiple and/or all check boxes? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to select multiple and/or all check boxes? (/Thread-How-to-select-multiple-and-or-all-check-boxes)



How to select multiple and/or all check boxes? - kalpana - 04-09-2013

Hi,

I have a scenario, to select multiple check boxes in one case and all check boxes for another case.

If any one can help me to make it work the above conditions.
screenshot is attached......
Thanks


RE: How to select multiple and/or all check boxes? - ravi.gajul - 04-09-2013

Use this code to select all check boxes in a page.
Code:
Set myObj=Description.Create
myObj("micclass").value="WebCheckBox"
Set allObjs=Browser("...").Page("....").ChildObjects(myObj)
For i=0 to allObjs.count
    allObjs(i).Set "ON"
Next
You can customize the above code to select all or few checkboxes as you need.


RE: How to select multiple and/or all check boxes? - kalpana - 04-09-2013

Thanks for the reply. I used similar to above code for selecting all check boxes. I need to know how to select multiple check boxes now.
All the properties are same for all of the check boxes, except value.
value is given like this xxx-123|1|, xxx-124|2|..etc

eg: check box -0 is for checking all
check box-1
check box-2
check box-3
check box-4
How to select check box-1,2 or only one check box-3

If any one can help me, know how to make it work all in the above conditions in one place..

Thanks


RE: How to select multiple and/or all check boxes? - ravi.gajul - 04-09-2013

Assuming you have four check boxes...if you were to select check box#3 and checkbox#4 you will use .
Code:
Set myObj=Description.Create
myObj("micclass").value="WebCheckBox"
Set allObjs=Browser("...").Page("....").ChildObjects(myObj)
allObjs(2).Set "ON"
allObjs(3).Set "ON"
This approach doesn't take into consideration, the check box properties. It gets all checkbox items and selects all if used in for loop. To select a particular check box, pass its index where the first occurence of a check box is given index '0'.