扩展QTP的WebTable测试对象
来源:互联网 发布:mac自带的画图软件 编辑:程序博客网 时间:2024/06/06 03:14
WebTable是使用QTP进行WEB页面测试时经常碰到的测试对象,由于WebTable可以嵌套,因此通常需要用ChildItem来获取嵌套的子元素
可以封装一些方法来扩展WebTable测试对象,简化测试脚本的实现,例如返回WebTable中包含的指定类型(MicClass)的测试对象。
以下脚本摘自QTP的CodeSamplesPlus:
' Function: ObjectsByMicClass
' Description: Returns a collection of objects all the objects in a
' WebTable that have the specified MicClass
' Return Value: A Collection of Objects
' Arguments:
' Obj - Test Object (WebTable)
' micClass - The micClass of the objects to retrieve
'-----------------------------------------------------------------------------------------------------------
Function ObjectsByMicClass(Obj, micClass)
Set Table = Obj
' Create a collection object to hold the items
Set objCollection = CreateObject("Scripting.Dictionary")
' Go over all the cells in the table, and look for objects with the specified micClass
For row=1 to Table.RowCount
ColumnCount=Table.ColumnCount(row)
For col=1 to ColumnCount
For ItemIndex=0 to Table.ChildItemCount(row, col, micClass)-1
Set childItem=Nothing
Set childItem = Table.ChildItem(row, col, micClass, ItemIndex)
If Not childItem is Nothing Then
' If the cell contains a micClass object, add it to the collection
ItemKey = objCollection.Count + 1
objCollection.Add ItemKey, childItem
End if
Next
Next
Next
Set ObjectsbyMicClass = objCollection
End Function
RegisterUserFunc "WebTable","ObjectsByMicClass","ObjectsByMicClass"
使用ObjectsByMicClass的例子:
Set collection = Browser("Browser").Page("Web Tours").Frame("info").WebTable("Joseph Marshall 's Flight").ObjectsByMicClass("WebCheckBox")
For i=1 to collection.count
If collection(i).GetROProperty("checked") Then
collection(i).Set "OFF"
Else
collection(i).Set "ON"
End If
Next
- 扩展QTP的WebTable测试对象
- 在QTP中巧用WebTable对象的ChildItem方法进行测试
- 在QTP中巧用WebTable对象的ChildItem方法进行测试
- QTP webTable
- QTP 获取WebTable单元格中的对象
- QTP之WebTable----搜索指定的数据
- 《精通QTP-自动化测试技术领航》学习笔记5-webtable
- qtp遍历webtable
- QTP webTable 相关2
- 【QTP】取出WebTable中的数据
- QTP读取webTable最后一行
- 管理QTP测试脚本的对象仓库
- QTP测试不同对象
- QTP中的WebTable中的GetRowWithCellText方法改进
- QTP实用函数(包括WEBTABLE等)
- QTP实用函数(包括WEBTABLE等)
- 使用QTP测试ActiveX对象
- 在QTP中自定义测试对象WinList的Select方法
- 宏定义使用学习
- Windows和Linux间文本文件格式转换
- 学习操作系统了哦,呵呵!!
- SCWCD之路——序言
- 应该如何正确对待员工的抱怨
- 扩展QTP的WebTable测试对象
- log4j学习札记
- [转帖]输入一个新的网址后到完全显示页面,浏览器做了哪些工作?
- 半自动化ORM:iBATIS
- reactos操作系统实现(175)
- struts二 adtion 中取得取得和设立application,request,session,response
- 用 Hadoop 进行分布式并行编程, 第 1 部分
- 欲知Tomcat, 推荐一本书。
- Hadoop分布式文件系统:架构和设计要点