簡體   English   中英

QTP讀取Webtable內容

[英]QTP read webtable content

我在QTP中有一個WebTable,例如:

<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>

在這里,我想捕獲每個divRow的值divFirst和divData,理想情況下,將每個divRow存儲在字符串中。

有人可以告訴我該怎么做嗎?

非常感謝

這似乎可行:

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

我使用描述性編程的索引將用完的原因是ChildObjects不返回這些WebElements

(顯然,您需要使用MsgBox值來做其他事情。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM