如何使用 selenium IDE 查找文本包含的 xpath 和该行中的 select 复选框

How to find xpath for text contains and select check box in that row using selenium IDE

我的 table 中有 3 行,我想 select 一个包含文本 1024.0281 的复选框。我可以找到包含零件号的文本 xpath=//a[text()='1024.0281']

但我不知道如何 select 该行中的复选框,该怎么做? 我正在尝试在 Selenium IDE 中执行此操作。 先感谢您!

<tbody>
  <tr class="odd">
    <td><input class=RightText name='DHR' type='checkbox' id='Chk_DHR0' value='1^310^0^^^^' onClick=javascript:fnCalcDHRAmt( 'Chk_DHR0',this.form) tabindex="8"><input type=hidden name='hDHRID0' value='GM-DHR-200789551'> <input type=hidden name='hVID0' value='334'>      <input type='hidden' value='0' name='hDHRAmtGMDHR200789551'></td>
    <td>PS-1876546</td>
    <td><a title="7.5mm REVERE HA Monoaxial Screw, 27mm">1024.0131</a></td>
  </tr>
  <tr class="even">
    <td><input class=RightText name='DHR' type='checkbox' id='Chk_DHR1' value='1^465^0^^^^' onClick=javascript:fnCalcDHRAmt( 'Chk_DHR1',this.form) tabindex="9"><input type=hidden name='hDHRID1' value='GM-DHR-200789552'> <input type=hidden name='hVID1' value='334'>      <input type='hidden' value='0' name='hDHRAmtGMDHR200789552'></td>
    <td>PS-1876546</td>
    <td><a title="8.5mm REVERE HA Monoaxial Screw, 25mm">1024.0281</a></td>
  </tr>
  <tr class="odd">
    <td><input class=RightText name='DHR' type='checkbox' id='Chk_DHR2' value='1^1000^0^^^^' onClick=javascript:fnCalcDHRAmt( 'Chk_DHR2',this.form) tabindex="10"><input type=hidden name='hDHRID2' value='GM-DHR-200789553'> <input type=hidden name='hVID2' value='334'>      <input type='hidden' value='0' name='hDHRAmtGMDHR200789553'></td>
    <td>PS-1876546</td>
    <td><a title="REVERE  4.5 Thoracic Lamina Hook, Narrow, Medium">1041.9902</a></td>
  </tr>
</tbody>

使用下面的xpath,将select基于anchor texttr,然后找到输入复选框。

//tr[.//a[text()='1024.0281']]//input[@class='RightText']

或使用前面的

//a[text()='1024.0281']/preceding::input[@name='DHR'][1]