QTP中针对不同类型语言编写的计算器的测试脚本

表达对语言支持的重要性,不同的对象需要不同的对象支持

1.VB

Dim CalcStr
CalcStr=Inputbox("Please input Calc","Calc","95-27=")

VbWindow("Form1").Activate

For i = 1 To len(CalcStr) 
    VbWindow("Form1").VbButton("1").SetTOProperty "text",mid(Calcstr,i,1)
    VbWindow("Form1").VbButton("1").Click
Next 
Result = VbWindow("Form1").VbLabel("Label1").GetROProperty("text") 
print Result
VbWindow("Form1").VbButton("清    除").Click

2.windows

For i=1 To 100 
ilen=len(i)
For  p=1 to ilen
    cButton=cstr(mid(i,p,1))
    Dialog("小蔡计算器").WinButton("1").SetTOProperty "Text", cButton
    Dialog("小蔡计算器").WinButton("1").Click    
Next
Dialog("小蔡计算器").WinButton("1").SetTOProperty "Text""+"
Dialog("小蔡计算器").WinButton("1").Click    
Next

 

3.如何没有支持的,就只能用描述性编程

precondition:要先获取一个button的对象

'Window("regexpwndtitle:=小蔡计算器").Highlight

For i = 1 To 50
ilen=len(i)
For p=1 to ilen
    button1="Text:="&Cstr(mid(i,p,1))
'    双引号内不能直接引用变量
    Window("regexpwndtitle:=小蔡计算器").WinButton(button1).Click 
    wait 1    
Next
Window("regexpwndtitle:=小蔡计算器").WinButton("text:=\+","nativeclass:=Button").Click    
''Dialog("小蔡计算器").WinButton("1").Click
Next 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值