检测语句嵌套到if语句
上一篇 /
下一篇 2010-11-12 14:58:06
/ 个人分类:QTP学习
写完脚本了,报语法错误,急性子的我火啊,本来对代码就不熟悉,还要报错,头大,刚学
QTP那阵子,就一个词形容我最恰当-- “焦头烂额”。
If Dialog("Lemon").WinButton("online status").Check CheckPoint("online status_2")Then
Dialog("Lemon").WinButton("online status").Click
End If
这行代码怎么会错?后来找开发同事(之前做过一段时间脚本开发)来看了下,告诉我CheckPoint("online status_2")要用括号括住,否则空格可能会默认语句断开了,无语,代码知识有点缺乏,还好有广大的开发朋友圈(呵呵,在此对他们表示感谢!),修改过后,代码如下:
If Dialog("Lemon").WinButton("online status").Check(CheckPoint("online status_2"))Then
Dialog("Lemon").WinButton("online status").Click
End If
ok!可以正常运行。(但运行结果中,if语句中的情况不存在的话,会报fail,未处理中... ...)
PS:之后经别人指点,知道if嵌套checkpoint这种做法不是很好,因为一般检测点false的话,运行结果中就要记录为fail。以上为错误示范,以后记住。
如果要用对象某个属性作为检测点的话,最好使用GetROProperty或GetTOProperty等等诸如此类的方法,如:
If Dialog("Lemon").Dialog("Lemon").Exist then
或者
If Dialog("Lemon").winedit("edit").GetROProperty("text") ="" then ' 用户名为空时登录
或者
if DataTable("password", dtGlobalSheet)="" then '表格形式参数化的内容
收藏
举报
TAG: