Selenium Automation-需要xpath来定位具有几乎相同属性的2个UI元素,它们位于不同的HTML标签中

问题描述

这里的场景是我需要断言作业名称的状态是否更改为“已完成”,但是问题是在UI页面上,作业状态HTML元素*(title =“ Completed”)*对于所有不同的工作名称*(title =“ Job1”)*。

下面是示例HTML代码:

<div class="flex-primary"><i title="Completed" class="fa fa-cube provider-logo hwx-secondary orange"></i><span class="hwx-title" title="Job1">Job1</span> &nbsp;</div>
<span><button class="btn btn-icon btn-transparent inline-overview-actions" eventkey="1" title="Completed"><i class="fa fa-play-circle hwx-secondary inline-actions-overview no-select"></i></button></span>

<div class="flex-primary"><i title="Completed" class="fa fa-cube provider-logo hwx-secondary orange"></i><span class="hwx-title" title="Job2">Job2</span> &nbsp;</div>
<span><button class="btn btn-icon btn-transparent inline-overview-actions" eventkey="1" title="Completed"><i class="fa fa-play-circle hwx-secondary inline-actions-overview no-select"></i></button></span>

<div class="flex-primary"><i title="Completed" class="fa fa-cube provider-logo hwx-secondary orange"></i><span class="hwx-title" title="Job3">Job3</span> &nbsp;</div>
<span><button class="btn btn-icon btn-transparent inline-overview-actions" eventkey="1" title="Completed"><i class="fa fa-play-circle hwx-secondary inline-actions-overview no-select"></i></button></span>

我想要一个定位器,该定位器将能够唯一地指向处于完成状态的职位,即:我想要一个xpath,它将作为低于2个xpath结果的组合输出:

//span[@title='job1'] and //button[@title='Completed']

注意:这是针对以下问题的后续问题 Selenium Automation - Need to combine 1 or more xpath locators to form a single locator

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)