QTP测试Windows计算器

来源:互联网 发布:ps软件官方免费下载 编辑:程序博客网 时间:2024/05/02 02:03

relevantcodes.com在《Automating Windows Calculator Part 1》这篇文章中介绍了用QTP测试Windows计算器的例子,对于初学者理解QTP自动化测试过程、函数的使用等方面的内容都很有帮助:

http://relevantcodes.com/automating-windows-calculator-part-1/

 

例如封装了一个函数叫TypeKey用于处理各个按钮的点击:

Function TypeKey(vKey)

       'Use a Select block for special regex characters

       Select Case vKey

              Case "*", "+", "+/-", "."

                     vKey = "/" & vKey

              Case "M+"

                     vKey = "M/+"

       End Select

 

       With Window("nativeclass:=SciCalc", "index:=0")

              .WinButton("text:=" & vKey).Click

       End With

End Function

 

调用方法:

TypeKey "1"

TypeKey "*"

TypeKey "2"

TypeKey "+"

TypeKey "3"

TypeKey "="

 

MsgBox CalculatedValue

 

原创粉丝点击