QTP:获取复选框的值
我想知道 www.gmail.com 的主页上有多少个复选框,而且我想检查复选框是否被选中.....
我的代码是......
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
即使我选中了复选框(在这台计算机上记住我)并执行,c
的值始终为“OFF”上面的代码,但 c
的值始终为“OFF”
请帮助我解决这个问题 预先感谢...
请回复这一点..
I want to know that how many checkboxes are present on the home page of www.gmail.com and also I want to check the checkbox is checked or not .....
My code is....
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 of c
is always "OFF" even i checked the checkbox (Remember me on this computer) and execute the above code but value of c
is always "OFF"
Please help me on this
thanks in advance...
kindly reply on this..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在 Page 对象上运行
GetROProperty
函数,而不是您找到的复选框(我不知道为什么Page
有一个checked
属性),但如果您在ChildObjects
返回的测试对象上运行,您将获得正确的值(1 表示true
0 表示false
)。You're running the
GetROProperty
function on the Page object rather than the check-box you found (I don't know whyPage
has achecked
property) but if you run on the test object returned byChildObjects
you will get the correct value (1 fortrue
0 forfalse
).在代码中添加以上行,您将在消息框中得到正确的结果,对于“ON”,您将得到
1
,对于“OFF”,您将得到0
。Add above line in your code and you will get correct result in message box, for "ON" you get
1
, for "OFF"0
.