QTP函数练习--数组作为参数
''''使用范例
Set obj=Browser("name:=用户服务网登录").Page("title:=用户服务网登录")
msgbox Omni(obj,"WebEdit-html id-passport","-","default value")
执行结果:用户名/手机号/身份证
Omni "obj,"WebEdit-html id-passport-shmily","-",""
执行结果:用户名输入框中输入shmily成功
''''**************************************
函数功能:
根据参数内容执行相关的操作
1.如给WebEdit输入一个值,则strProperty为"WebEdit-html id-username-shmily"
函数使用方法为:Omni "obj,"WebEdit-html id-username-shmily","-",""
2.如需要选择WebList下的某一项("test"),则strProperty为"WebList-html id-type-test"
函数的使用方法:Omni "obj,"WebList-html id-type-test","-",""
3.如需要点击某个WebButton,则strProperty为"WebButton-name-确定"
函数的使用方法:Omni "obj,"WebButton-name-确定","-",""
4.如需要获取某个WebElement的Innertext,则strProperty为"WebElement-html id-content"
函数使用方法为:va=Omni(obj,"WebElement-html id-content","-","Innertext")
va即为所需要的属性值。
Function Omni(upperObj,strProperty,separator,getProperty)
''''*********************************************************************
''''upperObj为控件的上层对象,如Browser(xxx).Page(xxx).Frame(xxx)等
''''strproperty为控件类型,属性和属性值的连接字符串,eg:WebEdit-html id-engine-name-发动机等
''''separator为属性值的分隔符,如上面采用的即是"-"
''''getProperty为期望获取的控件属性名称,如:name,此项如果为空,则判断不需要返回属性值
''''**********************************************************************
Dim arrPropertys,i ''''strProperty分割后的字符串数组
Dim typesDesc ''''虚拟对象-用来保存不同类型的控件属性和属性值
''''使用Description来存储输入的strProperty来赋值
Set typesDesc=Description.Create()
If InStr(strProperty,separator)=0 Then ''''如果分隔符的数目为0,则判断属性(值)格式错误
Msgbox "分隔符不正确或者缺少属性(值),请检查strProperty的内容"
Else
arrPropertys=Split(strProperty,separator)
If UBound(arrPropertys) mod 2<>0 Then ''''如果UBound()为奇数,则结构为:type+property+propertyValue+set(select)Value
''''循环给控件传进属性和属性值
For i=1 to UBound(arrPropertys)-2 Step 2
typesDesc(arrPropertys(i)).Value=arrPropertys(i+1)
Next
''''暂时只考虑了WebEdit和WebList,后续补充
Select Case LCase(arrPropertys(0))
Case "webedit"
upperObj.WebEdit(typesDesc).Object.Value=arrPropertys(UBound(arrPropertys))
Case "weblist"
upperObj.WebList(typesDesc).Select arrPropertys(UBound(arrPropertys))
End Select
Else ''''如果UBound()为偶数,则结构为:type+property+propertyValue
''''循环给控件传进属性和属性值
For i=1 to UBound(arrPropertys)-1 Step 2
typesDesc(arrPropertys(i)).Value=arrPropertys(i+1)
Next
''''暂时只考虑了Link,WebButton,WebEdit,WebElement,WebList,后续补充
If Len(getProperty)=0 Then
Select Case LCase(arrPropertys(0))
Case "link"
upperObj.Link(typesDesc).Click
Case "webbutton"
upperObj.WebButton(typesDesc).Click
Case "webelement"
upperObj.WebElement(typesDesc).Click
End Select
Else
Select Case LCase(arrPropertys(0))
Case "link"
Omni=upperObj.Link(typesDesc).GetROProperty(getProperty)
Case "webedit"
Omni=upperObj.WebEdit(typesDesc).GetROProperty(getProperty)
Case "weblist"
Omni=upperObj.WebList(typesDesc).GetROProperty(getProperty)
Case "webbutton"
Omni=upperObj.WebButton(typesDesc).GetROProperty(getProperty)
Case "webelement"
Omni=upperObj.WebElement(typesDesc).GetROProperty(getProperty)
End Select
End If
End If
End If
Set arrPropertys=Nothing
Set typesDesc=Nothing
Set i=Nothing
End Function
分享到:
相关推荐
破解java插件 (1)进入注册表,将HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive备份 (2)找到HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Add-In Manager\java,将名称为...
qtp代码框架------一位高手的杰作,里面是根据EXCEL文件进行读取参数,并把结果写入EXCEL参数,其中还包括参数的验证
QuickTest Professional QTP82-java-addin
QTP11补丁下载 - 增强WPF对象识别以及问题修复 QTPNET_00062.EXE
QTP 10.0 补丁-QTP_00599.exe
qtp入门到精通,介绍qtp工具的界面操作及录制脚本到手动编写脚本
QTP11补丁 - 支持chrome浏览器补丁
QTP学习历程--从工具使用到框架思想 .
QTP Session1-2 推荐资料,2个PPT文件,但是很讲解全面,特别适合新手学习,有经验的也可以作为参考。
QTP-TS-06数据库设计说明书V1-0
3.1. QTP中几个截取字符串的函数 18 4. "+" "&"的区别 20 5. QTP场景恢复 21 6. QTP中测试环境的初始化 27 7. QTP将数据库中的数据导入到excel 29 8. 在QTP中将数据库的数据导入到EXCEL 29 9. QTP将数据测试驱动 31 ...
AEC - Q102-003 Initial Release - Combined QTP-Data-Superset Template: Combined Qualification Test Plan, Qualification Data Presentation, and Superset of Tests(如 AEC - Q102-003 Rev- 中发布)
QTP正则表达式,很好的资源,不仅仅只针对于QTP
安装破解好的QTP是不可以运行j2ee程序的,需要安装QTP Java Add-in插件,安装后的破解方法
QTP的参数化-DataTable QTP操作Action QTP验证点与测试报告 VBS基础 常用WEB控件介绍 AOM 场景恢复 正则表达式的运用 Html中DOM的运用 函数资源库 环境变量 常用保留对象 VBS-操作文件 VBS-正则表达式
这是以前自己写的一些关于QTP的课件,先只上传一个。
newtours源码,可以学到很多QTP知识
(2)掌握QTP标准检查点的设置方法。 (3)掌握QTP动态捕捉信息与循环脚本的设计的方法。 2实验要求 (1)使用QTP对订票程序的Insert order功能进行测试,验证订票是否成功。 (2)掌握在QTP中检查点的添加方法。 ...
Quick Test Professional 插件 QTP82 .NET add-in