Public Function Gen_excepData(byval dObj,byRef oScript) ‘ 异常值,正确值,异常类型,异常参数 Dim errorValue,CorrectValue,expType,expPara Dim objName,scriptstr Dim i,j,expItem expItem = 0 ‘ 记录异常数 Randomize
for i = 1 to DataTable.GetSheet("UserData").GetParameterCount ‘ 第一行数据为默认正确数值 CorrectValue = DataTable.GetSheet("UserData").GetParameter(i).ValueByRow(1) datatable.SetCurrentRow 2
if Instr(Datatable.value(i,"UserData"),"exp@@")>0 Then objName = dObj.Item(Datatable.value(i,"UserData")) ‘ 同一字段多种异常策略的处理 arr1 = split (Datatable.value(i,"UserData"),"|",-1,1) For j = 0 to Ubound(arr1) ‘ 获取异常类型和异常参数 If RegExpTest("exp@@.{1,}/(.{1,}/)",arr1(j)) Then exptype = Mid(arr1(j),6,InStr(arr1(j),"(")-6) expPara = Mid(arr1(j),InStr(arr1(j),"(")+1,InStr(arr1(j),")")-InStr(arr1(j),"(")-1) Else expType = replace(arr1(j),"exp@@","") End If ‘ 不同策略对应的数据生成 select Case expType Case "SpecialChar" errorValue = Replace(CorrectValue,Right(CorrectValue,1),"%") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"'") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"/") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),":") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"*") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"&") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"?") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"""") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"<") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),">") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"|") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),"(") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr errorValue = Replace(CorrectValue,Right(CorrectValue,1),")") scriptstr = objName + chr (34) + errorValue + chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "StringLenMax" errorValue = CorrectValue Dim n For n = 1 to expPara+1-Len(CorrectValue) errorValue = errorValue & chr(Int(26 * Rnd + 97)) Next scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "StringLenMin" errorValue = Left(CorrectValue,expPara-1) scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "String" errorValue = "" Dim n For n = 1 to Len(CorrectValue) errorValue = errorValue & chr(Int(10 * Rnd + 48)) Next scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "Num" errorValue = Left(CorrectValue,Len(CorrectValue)-1) & chr(Int(26 * Rnd + 97)) scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "NumMax" errorValue = expPara + 1 scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "NumMin" errorValue = expPara - 1 scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "NumLenMax" errorValue = CorrectValue Dim n For n = 1 to expPara+1-Len(CorrectValue) errorValue = errorValue & chr(Int(10 * Rnd + 48)) Next scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "NumLenMin" errorValue = Left(CorrectValue,expPara-1) scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "StringPre" Dim n,tmpStr tmpStr = "" For n = 1 to Len(expPara) tmpStr = tmpStr & chr(Int(26 * Rnd + 97)) Next errorValue = Replace(CorrectValue,expPara,tmpStr) scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "NumPre" Dim n,tmpStr tmpStr = "" For n = 1 to Len(expPara) tmpStr = tmpStr & chr(Int(10 * Rnd + 48)) Next errorValue = Replace(CorrectValue,expPara,tmpStr) scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "Email" errorValue = Replace(CorrectValue,"@",chr(Int(26 * Rnd + 97))) errorValue = Replace(errorValue,".",chr(Int(26 * Rnd + 97))) scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr Case "Need" errorValue = "" scriptstr = objName & chr(34) & errorValue & chr(34) expItem = expItem + 1 oScript.add "excepData" & expItem,scriptstr End Select Next End If Next
End Function
|
相关推荐
QTP检查点使用与分析
QTP检查点使用的PPT演示文稿,讲解非常详细,包括录制脚本、检查点设置、参数化等。
关于QTP检查点的叙述,即检查点类型及如何创建检查点。
QTP插入检查点. 和循环实现
自己整理的QTP基本使用方法,Word版!肯定对你有所帮助!
QTP安装和使用教程; QTP自动化测试; QTP安装过程中的注意事项;
QTP使用小结,叫你如何使用QTP,本人的心得体会,欢迎下载!
QTP入门-检查点输出值参数化 录像 检查点 输出值 参数化 同步点 1.检查点 目的: 检查点比较指定属性的当前值与期望值,以判断当前的程序(或站点)功能是否正常。 在密码正确的情况下预期结果是进入主界面,检查...
这是我找的QTP中文使用教程,希望能帮助开始着手学习QTP的伙伴。大家一起加油。
Qtp在录制过程中添加检查点步骤: A问题描述: 在录制过程中添加检查点可以避免在编辑脚本时无法添加需要检查点的问题 B处理流程: B1从录制界面切换到qtp B2添加检查点 B3设定检查点 B4继续录制 C术语说明
给初级学习qtp的测试人员提供的在录制时不理解的描述信息
包括(文本检查点,标准检查点,表格检查点,网页检查点)(图片检查点,数据库检查点,xml文件检查点还没有具体操作) 3.对脚本的检查点和输入数据等进行参数化(文本框,标准检查点,表格检查点的输入)。 4.参数...
1实验目的 (1)理解和掌握自动化测试的基本原理和方法。...(2)掌握在QTP中检查点的添加方法。 (3)使用QTP对被测程序AUT进行动态信息捕捉的操作。 (4)掌握对测试脚本中取出多个值进行循环脚本的设计。
QTP高级5_QTP中使用正则表达式,适合QTP(UFT)初级学习。
这是以前自己写的一些关于QTP的课件,先只上传一个。
3.1 QuickTest检查点种类 3.2 创建检查点 3.3 执行并分析使用检查点的测试脚本
QTP使用说明,外包,自动化测试使用工具,主要是用QTP和QC
QTP对象库简介
QTP使用手册 qtp base code.doc QuickTest Pro 8.2 Tutorial.ppt 一位高人的QTP学___
QTP软件测试工具中文使用说明,比较简单,适合初学者