QTP读取webtable内容

发布于 2024-09-04 01:49:53 字数 790 浏览 7 评论 0原文

我在 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 存储在字符串中。

有人可以告诉我该怎么做吗?

多谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待我真够勒 2024-09-11 01:49:53

这似乎有效:

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 之外。)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文