qtp脚本如下
'1、目录生成
Dim testpath
testpath=Environment.Value("TestDir")
testpaths=split(testpath,"testscript")
'msgbox testpaths(0)
executefile testpaths(0)& "commomlib通用函数\creat folder.vbs"
genfolder testpaths(0)&"testlog"
genfolder testpaths(0)&"testpic"
'2、测试用例加载
'判断测试用例是否存在
Dim fso
Dim oacaseexist
Dim casepath
casepath =testpaths(0)&"testcase\oacase.xlsx"
Set fso=createobject("scripting.filesystemobject")
oacaseexist=fso.FileExists(casepath)
If oacaseexist Then
'datatable.ImportSheet casepath,"Login",1,"Action1"
datatable.ImportSheet casepath,"Login","Action1"这句有问题
else
reporter.ReportEvent micFail,"Login test","测试用例不存在"
ExitTest
End If
'3、日志生成
'4、应用程序启动
openapp "iexplore.exe","iexplore.exe","http://w.oa.cn"
Sub OpenApp(APPName,AppPath,AppParam)
Dim gobj,wsh,proc
Dim i
On error resume next
Set gobj=getobject("winmgmts:\\.\root\cimv2")
Set wsh=createobject("wscript.shell")
Set proc=gobj.execquery("select * from win64_process where name="&"'"&AppName&"'")
For each i in proc
systemutil.CloseProcessByName(AppName)
wscript.quit
Next
End Sub
'5、测试对象加载
loadtrs testpaths(0)&"testobject对象\login.tsr"
Sub loadtrs(trsname)
repositoriescollection.RemoveAll
repositoriescollection.Add trsname
End Sub
executefile "F:\oatest\testscript\login.vbs"