Micro Focus QTP (UFT) Forums
How to click on a Checkbox in a webtable - 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: How to click on a Checkbox in a webtable (/Thread-How-to-click-on-a-Checkbox-in-a-webtable)



How to click on a Checkbox in a webtable - vjjohnson04 - 10-23-2012

Hi all,

[Image: 7Zkd30GRIPbB]

I'm trying to get the count of check-boxes in column 1 from a webtable as seen in the image attached and click on the first 10 records setting them to on.

Code:
Code:
Set oPage = Browser("micClass:=Browser").Page("micClass:=Page")
Result_Grd = "html id:=ResultGridCtl"

Set oChkBox = Description.Create()
oChkBox("micClass").value = "WebCheckBox"
oPage.WebTable(Result_Grd).highlight
If oPage.WebTable(Result_Grd).Exist Then

wbChkCount = oPage.WebTable(Result_Grd).ChildObjects(oChkBox) .count

End If

http://screencast.com/t/7Zkd30GRIPbB
The above code gives me the count of all check-boxes in the WebTable.

Can some one help as I'm stuck on this.


RE: How to click on a Checkbox in a webtable - ssvali - 10-23-2012

Try the below code... I added to ur code


Code:
Set oPage = Browser("micClass:=Browser").Page("micClass:=Page")
Result_Grd = "html id:=ResultGridCtl"

Set oChkBox = Description.Create()
oChkBox("micClass").value = "WebCheckBox"
oPage.WebTable(Result_Grd).highlight
If oPage.WebTable(Result_Grd).Exist Then

wbChk = oPage.WebTable(Result_Grd).ChildObjects(oChkBox)

For i = 1 to wbChk.Count - 1

    wbChk(i).highlight
    wbChk(i).Set ON

    If i > 10 Then
        Exit For
    End If

Next



RE: How to click on a Checkbox in a webtable - vjjohnson04 - 10-23-2012

Thanks for the help just modified the a few things and it works PERFECT Smile .

Code:
Code:
Set oPage = Browser("micClass:=Browser").Page("micClass:=Page")
Result_Grd = "html id:=ResultGridCtl"

Set oChkBox = Description.Create()
oChkBox("micClass").value = "WebCheckBox"
oChkBox("disabled").value = 0
oPage.WebTable(Result_Grd).highlight
If oPage.WebTable(Result_Grd).Exist Then

Set wbChk = oPage.WebTable(Result_Grd).ChildObjects(oChkBox)

For i = 1 to wbChk.Count - 1

     wbChk(i).highlight
     wbChk(i).Set "ON"

    
     If i > 10 Then
         Exit For
     End If

Next            
End If



RE: How to click on a Checkbox in a webtable - ssvali - 10-23-2012

My pleasure.
Glad that it worked for you. Smile


RE: How to click on a Checkbox in a webtable - vjjohnson04 - 10-25-2012

What if I have 2 columns with check boxes and want to set the value of all check boxes only in 1 column. How do i do that?