QTP read webtable content
I have a WebTable in QTP like:
<TBODY>
<TR></TR>
<TR>
<TD>
<TABLE>
<TR>
<TD>
<DIV class=divRow id=divRow_d_0>
<DIV class=divFirst>1</DIV>
<DIV class=divData>toto</DIV>
<DIV class=divData>fofo</DIV>
</DIV>
<DIV class = divRow id=divRow_d_1>
<!--same structure here-->
</DIV>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR></TR>
</TBODY>
Here, I want to capture the values divFirst and divData for each divRow, 开发者_运维技巧ideally, store every divRow in a string.
Could someone please tell me how can I do that?
Thanks a lot
This seems to work:
Set RowDesc = Description.Create()
RowDesc("class").Value = "divRow"
RowDesc("index").Value = 0
Set DataDesc = Description.Create()
DataDesc("class").Value = "divData"
While Browser("Browser").Page("Page").WebElement(RowDesc).Exist(1)
Set Row = Browser("Browser").Page("Page").WebElement(RowDesc)
RowDesc("index").Value = RowDesc("index").Value + 1
MsgBox Row.WebElement("class:=divFirst").GetROProperty("innertext")
DataDesc("index").Value = 0
While Row.WebElement(DataDesc).Exist(1)
Set Datum = Row.WebElement(DataDesc)
MsgBox Datum.GetROProperty("innertext")
DataDesc("index").Value = DataDesc("index").Value + 1
Wend
Wend
The reason I'm using descriptive programming with an index that will run out is that ChildObjects
does not return these WebElements
(Obviously you will want to do something other than MsgBox with the values.)
精彩评论