Micro Focus QTP (UFT) Forums
Selecting Check boxes by Descriptive Programming - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Selecting Check boxes by Descriptive Programming (/Thread-Selecting-Check-boxes-by-Descriptive-Programming)



Selecting Check boxes by Descriptive Programming - sunny rao - 12-11-2008

Hi Ankur and all,

I am trying to use DP to check all checkboxes on a particular page.

Depending on my product selection on earlier pages 3 or 4 checkboxes are visible remaining are hidden. when I count

Code:
Set ParentW=Browser("abc").Page("xyz")

Set objdesc=Description.Create()
objdesc("type")="checkbox"
Set objparent=ParentW.ChildObjects(objdesc)
ckboxcount=objparent.count()
msgbox ckboxcount

The result is I get 12 checkboxes since only 3 or 4 are visible at a time and others are hidden. How to solve this problem.


RE: Selecting Check boxes by Descriptive Programming - rnickerson - 12-13-2008

I'd try something like this:

Code:
Function CheckAll()
    Dim oDesc: Set oDesc = Description.Create
    oDesc("micclass").Value = "WebCheckBox"
    oDesc("visible").Value = True
    Dim colCheckboxes: Set colCheckboxes = Browser().Page().ChildObjects(oDesc)
    'msgbox colCheckboxes.Count
    Dim i
    For i = 0 To colCheckboxes.Count -1
        colCheckboxes(i).Set "ON"
    Next
End Function

Clearly you would need to provide the Browser and Page descriptions/objects, but then this should show you the number of checkboxes (uncomment the msgbox line) and check them.

I hope this helps.


RE: Selecting Check boxes by Descriptive Programming - bfakruddin - 12-22-2008

Code:
Option Explicit
'On Error Resume Next
Dim co,v,j,val

systemutil.run "www.yahoomail.com"
wait(3)
val=browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").WebEdit("login").GetROProperty("value")
print val

Function Yahoo()

    If browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").Exist Then
            Yahoo=browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").Exist
        Dim co
    
        Set co=description.Create()
    
        co("micclass").value="WebCheckBox"
        co("visible").value=True
    
        set v=browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The best").ChildObjects(co)
        j=v.count
        print j
    
        For i=0 to j-1
            v(i).set "ON"
        Next

    End If
End Function

Call Yahoo()
msgbox Yahoo



RE: Selecting Check boxes by Descriptive Programming - sunny rao - 01-08-2009

Thanks guys your suggestion helped me.