QTP: get checkbox value

I want to know how many checkboxes are there on the www.gmail.com homepage and also I want to check the checkbox is checked or not .....

My code ....

Set obj= Description.Create()
obj("name").value="PersistentCookie"
obj("html tag").value="INPUT"
obj("type").value="checkbox"

Set a = Browser("name:=Gmail.*","title:=Gmail.*").Page("title:=Gmail.*").Childobjects(obj)
MsgBox a.count

c =Browser("name:=Gmail.*", "title:=Gmail.*").Page("title:=Gmail.*").GetROProperty("checked")
MsgBox c

      

The value is c

always "OFF", even I checked the box (remember on this computer) and ran the above code, but the value is c

always "OFF"

Please help me with this thanks in advance ...

kindly answer this.

+1


source to share


2 answers


You are using the function GetROProperty

on the Page object, not the checked box (I don't know why it Page

has the property checked

), but if you run the test object returned on ChildObjects

you will get the correct value (1 for true

0 for false

).



c = a(0).GetROProperty("checked") 

      

+2


source


c = Browser("name:=Gmail.*","title:=Gmail.*").Page("title:=Gmail.*").WebCheckBox("name:=PersistentCookie").GetROProperty("checked")

      



Add the above line to your code and you will get the correct result in the message box, for "ON" you get 1

, for "OFF" 0

.

+2


source







All Articles