如何遍历WebTable中的单元格

来源:百度文库 编辑:神马文学网 时间:2024/04/26 10:28:30

如何遍历WebTable中的单元格

QTP中的WebTable测试对象提供了RowCount和ColumnCount,可用于遍历WebTable中的所有单元格。

  1. Set wtObj = Browser(XXX).Page(XXX).WebTable(XXX)
  2. For i = 1 To wtObj.RowCount
  3. For j =1 To wtObj.ColumnCount(i)
  4. 'Set cellLink = wtObj.ChildItem(i,j,"Link",0) '取每个单元格中的链接对象
  5. msgbox wtOjb,GetCellData(i,j) '取每个单元格的内容
  6. Next
  7. Next

其中用到了两个方法
object.ChildItem (Row, Column, MicClass, Index)
object.GetCellData(Row, Column)
Row - 行号
Column - 列号
MicClass - 对象的类型
Index - 对象的索引序号,比如如果取第一个符合条件的对象,则index=0