|
一、已实现的功能列表 框架已经实现的功能如下: 1、脚本数据分离 2、异常截图并关联截图 3、无界面启动UFT 4、定时启动UFT 5、步骤日志跟踪 6、数据库检查点验证 7、测试结果发送 8、测试报告生成 9、场景恢复 10、脚本执行速度控制 11、系统资源监控,如Cpu峰值监控(基于UFT) 12、执行过程录制回放(基于UFT)
二、框架部分关键代码1、必须导入的驱动脚本,用户全局环境控制 - Call driver()
- Function driver()
- '初始化环境,包括获得project所在的本地目录。
- projectPath = getProjectPath()
- sourceDataFile = projectPath&"\TEST.xls"
- sourceDataSheet = "Sheet1"
-
- Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
- Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
- Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
-
- Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
- qtApp.Launch ' Start QuickTest
- qtApp.Visible = True ' Make the QuickTest application visible
- ' Set QuickTest run options
- qtApp.Options.Run.CaptureForTestResults = "OnError"
- 'qtApp.Options.Run.RunMode = "Fast"
- qtApp.Options.Run.ViewResults = False
-
- ' 打开入口的测试脚本,并且加载testCase的脚本
- qtApp.Open projectPath&"\理赔系统流程", False, False ' 打开入口的测试脚本,可写,不保存
- Set qtTest = qtApp.Test
-
- ' set run settings for the test
- Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
- qtResultsOpt.ResultsLocation = projectPath&"\result" '运行结果保存到临时文件夹中
- qtTest.Run qtResultsOpt, True
复制代码
3、脚本代码片段,完整代码请见工程源码 - option explicit '规范声明
- '定义变量
- Dim ProjectDir '根目录
- Dim TestSetExcelFile '测试用例Excel路径
- Dim vbprpDuserUserCode1'定义用户名
- Dim vbprpDuserUserCode2'定义用户名
- Dim vbprpDuserPassword'定义密码
- Dim row_count ' Global中用例行数
- Dim rownum ' 当前运行的行
- Dim sqlstrm 'sql查询变量
- Dim keyname '数据库字段
- Dim TestCasesFile
- Dim SheetNameExcel
- Dim isRun
- Dim StartTime
- Dim EndTime
- Dim inRespTime
- Dim n '定义循环变量
- Dim vbprpNRegistReportorName1'定义客户名
- Dim vbprpNRegistReportorName'定义客户姓名
- Dim vbprpNRegistDamageAddress'定义出险地点
- Dim vbprpNRegistDamageCourse'定义出险过程
- Dim vbprpNRegistCarDriverPhoneNumber'定义客户联系方式
- Dim vbprpNRegistCarDrivingLicenseNo'客户证件号
- Dim vbprpNRegistCarDrivingLicenseNo2'三者证件号
- Dim vbprpNRegistCarDriverPhoneNumber2'三者联系方式
- Dim vbprpNRegistCarReportLoss'定义报损金额
- Dim vbBAOANNum1'定义商业险报案号
- Dim vbBAOANNum2'定义交强险报案号
- Dim vbJIEANNum
- Dim vbJIEANNum1
- Dim vbBAODANNum1'定义保单号
- Dim vbBAODANNum2
- Dim vbOutHospDate
- Dim vbAccountCode
- Dim accountcode
- Dim vbSHUNum'计算书号
- Dim vbPEIANNum'赔案号
- Dim vbSHUNum1
- Dim vbPEIANNum1
- Dim vbSHIGUNum'定义事故号
- Dim vbscheduleDeptCode'定义客户二账户名
- Dim vbLicenseNo'定义车牌号
- Dim JBYXSJ'定义日期
- '参数赋值
- '定义项目所在的根目录
- ProjectDir = getParentFolderPath(Environment.Value("TestDir")) '项目所在的根目录,
- 'msgbox ProjectDir
- Extern.Declare micVoid,"capture",ProjectDir&"CreateBitmap.dll","",micString
- '将用例转化为中间表
- TestCasesFile = ProjectDir&"TEST.xls" '管理所有测试用例的Excel文件的路径
- 'msgbox TestCasesFile
- SheetNameExcel = "Sheet1"
- Call carinsured()
- Function carinsured()
- JBYXSJ = FormateDateTime(date(),"3")
- vbOutHospDate = date+3
- Call DataTable.ImportSheet(TestCasesFile,"Sheet1","Global")
- row_count = DataTable.GetSheet("Global").GetRowCount'得到用例中总行数
- 'msgbox row_count
- '此处添加循环
- For n = 1 to row_count
- DataTable.GetSheet("Global").SetCurrentRow(n)
- datatable.Export ProjectDir&JBYXSJ&"流程验证结果.xls" '导出运行结果,生成result.xls文件
- '导入中间表
- TestSetExcelFile = ProjectDir&JBYXSJ&"流程验证结果.xls" '管理所有测试用例的Excel文件的路径
- Call DataTable.ImportSheet(TestSetExcelFile,"Global","Global")
- 'row_count = DataTable.GetSheet("Global").GetRowCount'得到用例中总行数
- isRun=DataTable.Value("RUN", "Global")
- If isRun = "Y" Then
- rowNum = datatable.GetSheet("Global").GetCurrentRow
- ' msgbox rowNum
- vbprpDuserUserCode1 = DataTable("帐号一","Global")
- vbprpDuserUserCode2 = DataTable("帐号二","Global")
- vbprpDuserPassword = DataTable("用户密码","Global")
- vbprpNRegistReportorName = DataTable("客户姓名","Global")
- vbprpNRegistDamageAddress = DataTable("出险地点","Global")
- vbprpNRegistDamageCourse = DataTable("出险经过","Global")
- vbprpNRegistCarDriverPhoneNumber = DataTable("客户联系电话","Global")
- vbprpNRegistCarDrivingLicenseNo = DataTable("客户证件号码","Global")
- vbLicenseNo = DataTable("客户车牌号","Global")
- vbprpNRegistCarReportLoss = DataTable("报损金额","Global")
- ...... '调用用户自定义的逻辑代码
- DataTable("流程是否通过") = "是"
- DataTable("备注") = "流程全部通过"
- datatable.ExportSheet ProjectDir&JBYXSJ&"流程验证结果.xls","Global" '导出运行结果,生成result.xls文件
- closeie()
- End If
- Next
- End FUNCTION
复制代码
|
|