QTP测试计算器(Cal.exe)例子,经过简单整理及排版,添加注释

Dim fsoInput,fsoOutput,fileInput,readstring,fileOutput,worksheetTmp
Dim one,two
Dim ipos,ilen
isheetrow=1
const forreading=1


set fsoInput=createobject("scripting.filesystemobject")
Set fileInput=fsoInput.opentextfile("E:/Project/QTPTest/TestCal/input.txt",forreading)
Set fsoOutput=createobject("excel.application")
Set fileOutput=fsoOutput.workbooks.open("E:/Project/QTPTest/TestCal/output.xls")
Set worksheetTmp=fileOutput.worksheets("sheet1")

Do while fileInput.atendofline<>true
readstring=fileInput.readline
ipos=instr(1,readstring,",",1)
ilen=len(readstring)
one=left(readstring,ipos-1)
two=right(readstring,ilen-ipos)  
Window("计算器").Activate
Window("计算器").WinButton(one).Click
Window("计算器").WinButton("+").Click
'此次加入catch的结果,(通过OUTPUT,和得到检查的值)
'获取运算符 g=Window("计算器").WinButton("+").GetROProperty("text")
'为期望结果作准备
g1=cdbl(one)+cdbl(two)
Window("计算器").WinButton(two).Click
Window("计算器").WinButton("=").Click
'此处加入判断,比如实际和期望结果比较的条件,来得到是否是失败还是成功 )
'目前只是输出运算值,结果,期望,实际值取法类似
worksheetTmp.cells(isheetrow,1)=g+cstr(isheetrow)
worksheetTmp.cells(isheetrow,2)=one
worksheetTmp.cells(isheetrow,3)=two
worksheetTmp.cells(isheetrow,4)=g1
isheetrow=isheetrow+1
loop
'过程结束!
Window("计算器").Close
'关闭文件流
fileInput.close
'清空文件流数据
fileOutput.close


set fileInput=nothing
set fsoInput=nothing
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值