【QTP实战】在WebTable对象中使用ChildItem方法

上一篇 / 下一篇  2011-05-03 16:23:09 / 个人分类:测试工具QTP

 

ChildItem方法
语法:
object.ChildItem (Row,Column,MicClass,Index)

作用:用于获取单元格中的测试对象

项目实战举例:
1、修改订单号为“DD0000315”的单据,点击操作列中对应的“修改”图标进入修改页面。

orderNo="DD0000315"
num=Browser("xx").Page("xx").Frame("xx").WebTable("xx").RowCount
For i=0 to num
   If Browser("xx").Page("xx").Frame("xx").WebTable("xx").GetCellData(i,2)=orderNo Then
   Browser("xx").Page("xx").Frame("xx").WebTable("xx").ChildItem(i,9,"WebElement",0).Click
'Index:0=修改,1=提交,2=入库通知,3=审核,5=打印
   End If
Next

2、选择订单号为“DD0000317”前面的复选框,点击操作栏中的的“提交”图标进入提交页面。

orderNo="DD0000317"
totalRowNumber=Browser("xx").Page("xx").Frame("xx").WebTable("xx").RowCount
For i=0 to totalRowNumber
 If Browser("xx").Page("xx").Frame("xx").WebTable("xx").GetCellData(i,2)=orderNo Then
    Browser("xx").Page("xx").Frame("xx").WebTable("xx").childitem(i,1,"WebCheckBox",0).Set "ON"
 End if
Next
Browser("xx").Page("xx").WebButton("提交").Click

>>项目实战操作图:

 

ChildItem

Description

    Returns a test object from the cell by type and index.

Syntax

   object.ChildItem(Row,column,MicClass,Index)

   object:A test object of type WebTable.

    Row:Required.A long value.The row number where the cell is located.The first row int the table is number 1.

    Column:Required.A long value.The column number where the cell is located.The first column in the table is 1.

    MicClass:Required.A string value.The object type.

    Index:Required.A long value.The index of the object of type MicClass in the cell.This index indicates the desired element when there is more then one object of the type MicClass in the cell.The first object has an index of 0.

Return Value

    An Object object

Example

    sub ChildItem_Example()

    'The following example uses the ChildItem method to set the second edit box from the FirstName table to Example.

    Set WebEditObj = Browser().Page().WebTable("FirstName").ChildItem(8,2,"webedit",0)

    WebEditObj.Set "Example"

    End sub


TAG:

引用 删除 xiaobing0107   /   2012-07-31 13:35:40
Thank you ,very helpful.
引用 删除 xiaobing0107   /   2012-07-31 13:35:00
5
 

评分:0

我来说两句

Open Toolbar