需要的对象:UFT

时间:2015-09-30 05:10:56

标签: qtp hp-uft

在这里无法继续。我处于这样一种情况,我根据索引选择一个webcheckbox。以下是我的代码

Set Brw = Browser("title:=.*").Page("title:=.*")

MilestoneTBLRow=brw.webtable("cols:=7","column names:=;Milestone Name;Milestone Date;Description;Created Time;Modified Time;Action").RowCount

MilestoneTBLCol=Brw.webtable("cols:=7","column names:=;Milestone Name;Milestone Date;Description;Created Time;Modified Time;Action").ColumnCount(1)

For i = 2 To MilestoneTBLRow  Step 1
    set MilestoneTBL = Browser("title:=.*").Page("title:=.*").webtable("cols:=7","column names:=;Milestone Name;Milestone Date;Description;Created Time;Modified Time;Action")
    `MilestoneTBL.childitem(i,1,"WebCheckBox",0).set "ON"
    Browser("title:=.*").Page("title:=.*").WebButton("name:=Mass Edit","type:=button","html tag:=INPUT","index:=0").click
    btnSave "0"
Next

错误发生在 Object required: 'MilestoneTBL.childitem(...) 从网表中,我需要根据索引选择webcheckbox。在这种情况下,索引从索引" 0"开始。 &安培;它位于第二排网表中。行号&索引在这里不匹配。如果索引为0,则行为2.我需要提供一个变量,该变量将使索引增加1.我已经尝试使用MilestoneTBLRow MilestoneTBL.childitem(i,1,"WebCheckBox",MilestoneTBLRow).set "ON" &返回错误 Object required: 'MilestoneTBL.childitem(...)

你可以在这里纠正我吗?

1 个答案:

答案 0 :(得分:2)

创建一个临时变量并在'for'循环中增加该变量,如此

temp=0
*Set Brw = Browser("title:=.*").Page("title:=.*")
MilestoneTBLRow=brw.webtable("cols:=7","column names:=;Milestone           Name;Milestone Date;Description;Created Time;Modified Time;Action").RowCount
MilestoneTBLCol=Brw.webtable("cols:=7","column names:=;Milestone Name;Milestone Date;Description;Created Time;Modified Time;Action").ColumnCount(1)
For i = 2 To MilestoneTBLRow  Step 1
set MilestoneTBL =   Browser("title:=.*").Page("title:=.*").webtable("cols:=7","column  names:=;Milestone Name;Milestone Date;Description;Created Time;Modified Time;Action")
`MilestoneTBL.childitem(i,1,"WebCheckBox",temp).set "ON"
 Browser("title:=.*").Page("title:=.*").WebButton("name:=Mass Edit","type:=button","html tag:=INPUT","index:=0").click
btnSave "0"
temp=temp+1
Next