【问题标题】:How to locate Button followed by card_header-title containing specific text in sample html如何在示例 html 中找到包含特定文本的 Button 后跟 card_header-title
【发布时间】:2019-05-05 03:29:38
【问题描述】:

如何在 Robot Test Framework 中选择 Actions Button 后跟包含已知文本的 Div 类(例如,在本例中为 card_header-title"Addresses")?

该页面包含几个跨度表部分,每个部分都有自己的操作和显示历史按钮。要选择特定的操作按钮,我可以使用它的 xpath,但我正在尝试访问 for 循环中的所有部分,并且一个部分中的操作按钮的 xpath 从另一个更改,所以硬编码不是我的选择.有人请帮忙。

<div class="attribute-group-header card__header">
  <h3 class="attribute-group-title card__header-title">Addresses</h3>
  <div class="floatright">
    <input type="button" class="action small btn" value="Actions">
    <input type="button" class="showHistory action small btn" value="ShowHistory">
  </div>
</div> 

【问题讨论】:

    标签: robotframework selenium2library


    【解决方案1】:

    我知道您说您不想使用 Xpaths,但也许这些示例之一可能会有所帮助。除了在按钮上提供 id 之外,我看不到任何其他方法可以实现您的要求。

    您可以使用 xpath 定位器,它首先找到“attribute-group-title card__header-title”元素的文本,然后选择以下同级 div,然后是输入:

    //*[contains(text(),'Addresses')]/following-sibling::div[1]//input[@value='Actions']
    

    【讨论】:

      猜你喜欢
      • 2011-03-26
      • 2010-10-11
      • 2017-01-24
      • 2018-01-14
      • 2012-09-01
      • 2013-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多