Can';无法使用xpath定位Web元素

Can';无法使用xpath定位Web元素,xpath,automated-tests,Xpath,Automated Tests,我想单击+图标,该状态名称的属性为数据stateid=1 但是当我尝试使用firepath查找web元素时 所有+图标与类具有相同的属性,因此,我无法单击特定的+图标 HTML代码: <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" href="#lob1" data-stateid="1"> <span class="tag tag-

我想单击
+
图标,该状态名称的属性为
数据stateid=1

但是当我尝试使用
firepath
查找web元素时
所有
+
图标与
具有相同的属性,因此,我无法单击特定的
+
图标

HTML代码:

<div class="panel-heading">
 <h4 class="panel-title">
  <a data-toggle="collapse" href="#lob1" data-stateid="1">
   <span class="tag tag-default tag-pill pull-xs-right">0</span>
    <i class="fa fa-plus pull-xs-right btn-country-list" onclick="GetLobPopUp('AL','Alabama')"/>
 </h4>
</div>
<div id="lob1" class="panel-collapse collapse in" style="height: auto;">
 <div class="panel-heading">
  <h4 class="panel-title">
   <a data-toggle="collapse" href="#lob3" data-stateid="3">
    <span class="tag tag-default tag-pill pull-xs-right">0</span>
     <i class="fa fa-plus pull-xs-right btn-country-list" onclick="GetLobPopUp('AZ','Arizona')"/>
 </h4>
</div>
<div id="lob3" class="panel-collapse collapse in" style="height: auto;">
 <div class="panel-heading">
  <h4 class="panel-title">
   <a data-toggle="collapse" href="#lob4" data-stateid="4">
    <span class="tag tag-default tag-pill pull-xs-right">0</span>
     <i class="fa fa-plus pull-xs-right btn-country-list" onclick="GetLobPopUp('AR','Arkansas')"/>
  </h4>
</div>

0
0
0
有人能帮我解决这个问题吗?

致以最诚挚的问候。

您需要做的就是首先使用不同的属性识别元素。。如果不能使用
,请使用
数据状态ID


//a[@data stateid='1']/以下同级::i

您可以尝试此查询:

//h4[./a[@data-stateid=1]]/i
(测试日期)


粘贴的HTML似乎有点格式错误,所以我更正了它。

否决投票的原因是,我想单击数据状态id=1,而您提供的数据状态id=3无效,对我来说不是必需的。对不起,我的错误,我错过了你想要的stateid=1,但我认为纠正它不需要太多努力,也不需要投反对票。我已经改正了!更新为向上投票。:)现在它是按照要求和行为正确。