如何获得多重 values in single xpath in selenium

问题描述 投票:0回答:1

我被困在创建在TR标签下的xpath,我想从每个TR标签获得td [2],td [3],td [4]和td [5]的值。见下面的HTML。

<tbody>
   <tr role="row" class="odd">
      <td><img src="/Content/Uploaded//Profile//MasterAdmin/ashishadmin/95.jpg" class="profilepic img-responsive img-circle"></td>
      <td>Ashish A Admin</td>
      <td>[email protected]</td>
      <td></td>
      <td>ashishadmin</td>
      <td><label class="chkcontainer pointer-none"><input type="checkbox" class="chk" checked="checked"><span class="checkmark"></span> </label></td>
      <td><i class="fa fa-circle text-warning"></i></td>
      <td><a href="/Admin/Admin/SaveMasterAdmin/47" class="btn btn-success m-l-5">Edit</a><a href="#" class="btn delete btn-danger m-l-5" onclick="DeleteData(this,47);">Delete</a></td>
   </tr>

   <tr role="row" class="even">
      <td><img src="/Content/Uploaded//Profile//MasterAdmin/shpatel/download.jpg" class="profilepic img-responsive img-circle"></td>
      <td>Shree A Patel</td>
      <td>[email protected]</td>
      <td>8767676766</td>
      <td>shpatel</td>
      <td><label class="chkcontainer pointer-none"><input type="checkbox" class="chk" checked="checked"><span class="checkmark"></span> </label></td>
      <td><i class="fa fa-circle text-warning"></i></td>
      <td><a href="/Admin/Admin/SaveMasterAdmin/31" class="btn btn-success m-l-5">Edit</a><a href="#" class="btn delete btn-danger m-l-5" onclick="DeleteData(this,31);">Delete</a></td>
   </tr>

   <tr role="row" class="odd">
      <td><img src="/content/custom/img/default-user.jpg" class="profilepic img-responsive img-circle"></td>
      <td>Ashish G Savaliya</td>
      <td>[email protected]</td>
      <td>7897897890</td>
      <td>asavaliya</td>
      <td><label class="chkcontainer pointer-none"><input type="checkbox" class="chk" checked="checked"><span class="checkmark"></span> </label></td>
      <td><i class="fa fa-circle text-warning"></i></td>
      <td><a href="/Admin/Admin/SaveMasterAdmin/32" class="btn btn-success m-l-5">Edit</a><a href="#" class="btn delete btn-danger m-l-5" onclick="DeleteData(this,32);">Delete</a></td>
   </tr>
</tbody>

想要从每一行创建唯一的2,3,4和5个TD值的xpath。请参阅下面我想要使用xpath打印的所有必需数据的图像。

enter image description here

selenium-webdriver xpath
1个回答
1
投票
//tr/td[position() >= 2 and position() <= 5]
© www.soinside.com 2019 - 2024. All rights reserved.