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

来源:互联网 发布:淘宝高端fake鞋店铺 编辑:程序博客网 时间:2024/05/17 09:23

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

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
原创粉丝点击