(转载)【QTP】取出WebTable中的数据

上一篇 / 下一篇  2013-06-14 15:51:25

先上一段脚本:

  1. '取出WebTable中所有数据  
  2. Dim otable  
  3. Set otable = Browser("XXXXX").Page("XXXXX").WebTable("XXXXX")  
  4.   
  5. oRow = otable.RowCount   '行  
  6. print "oRow = " & oRow  
  7. oCol = otable.ColumnCount(2)  '列  
  8. print "oCol = " & oCol  
  9.   
  10. Dim temp  
  11. For i = 1 to oRow  
  12.     temp = ""  
  13.     For j = 1 to oCol  
  14.         temp =  temp & otable.GetCellData(i,j) & " | "  
  15.     Next  
  16.     print temp  
  17. Next  
  18.   
  19. Set otable = Nothing  

这段脚本只是打印出WebTable中所有的内容。

然后介绍WebTable中最常用的2个方法

  • GetCellData

GetCellData的作用是获取指定单元格(指定行,指定列)的值

用法:object.GetCellData(RowColumn)

如:

  1. otable.GetCellData(2, 3)          '取出WebTable中,第2行,第3列的值  

  • ChildItem

ChildItem顾名思义就是子对象啦,比如需要勾选WebTable中的一个勾选框(WebCheckBox)。

用法:object.ChildItem (RowColumnMicClassIndex)

MicClass:对象控件的类名,如List、WebButton等。

Index:一般就填写0就好了。

如:

  1. Set oWebCheckBox =otable.ChildItem(3,1,"WebCheckBox",0)  
  2. oWebCheckBox.Set"on"                   '勾选  
  3. Set oWebCheckBox =Nothing

TAG:

 

评分:0

我来说两句

日历

« 2024-05-15  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 52337
  • 日志数: 64
  • 建立时间: 2012-04-10
  • 更新时间: 2013-11-29

RSS订阅

Open Toolbar