简体   繁体   English

QTP读取Webtable内容

[英]QTP read webtable content

I have a WebTable in QTP like: 我在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>

Here, I want to capture the values divFirst and divData for each divRow, ideally, store every divRow in a string. 在这里,我想捕获每个divRow的值divFirst和divData,理想情况下,将每个divRow存储在字符串中。

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 我使用描述性编程的索引将用完的原因是ChildObjects不返回这些WebElements

(Obviously you will want to do something other than MsgBox with the values.) (显然,您需要使用MsgBox值来做其他事情。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM