【问题标题】:Selenium IDE assert XML answerSelenium IDE 断言 XML 答案
【发布时间】:2017-05-13 21:48:03
【问题描述】:

我正在寻找一种断言 XML 结果文本的方法。 我用它来测试一些网络服务。

XML 如下所示:

<ProductsResult>
   <Total>12679</Total>
   <Duration>4099</Duration>
   <Hits>
      <Product>
         <ProductNumber>ABC</ProductNumber>
      </Product>
   </Hits>
   <HitsByProductNumber>
      <Product>
         <ProductNumber>ABC</ProductNumber>
      </Product>
   </HitsByProductNumber>
</ProductsResult>

现在我需要检查 ProductNumber 标签,但只是在“Hits”标签中。 检查所有 ProductNumber 标签是没有问题的。 我这样做是这样的:

<html>
   <body>
      <table>
         <tbody>
            <tr>
               <td>clickAndWait</td>
               <td>css=input.button</td>
               <td></td>
            </tr>
            <tr>
               <td>assertXpathCount</td>
               <td>//*[name() = 'ProductNumber' and text() = 'ABC']</td>
               <td>1</td>
            </tr>
         </tbody>
      </table>
   </body>
</html>

【问题讨论】:

  • 问题是什么?
  • 如何在“Hits”标签中查看“Product” ;-)
  • 我们找到了解决方案。这很容易... //*[name() = 'Hits']/*[name() = 'Product'] :)

标签: xml selenium firefox-addon automated-tests selenium-ide


【解决方案1】:

我们找到了答案。

这很容易。

我仍然使用 assertXpathCount 并在我使用的目标中:

//*[name() = 'Hits']/*[name() = 'Product']

现在我可以访问 Hits Tag 中的所有产品。

【讨论】:

    猜你喜欢
    • 2022-10-05
    • 2012-10-08
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多