Ich verwende Selen, um das Testen zu automatisieren. Ich habe ein Problem mit der Auswahl des Kontrollkästchens einer Tabellenzeile. Also verwende ich XPath, um dies zu tun. Ich muss die Zeile anhand des Dateinamens auswählen. Im Folgenden ist der HTML-Wählen Sie ein Kontrollkästchen basierend auf einem Spaltenwert mit XPath
HTML
<form id="Runs3" action="" method="post">
\t <table id="data_Runs1" class="project-data project-show-borders project-has-col-totals">
\t \t <tbody>
\t \t \t <tr class="project-alternate-row">
\t \t \t \t <td id="ext-gen3" class="project-selectors" nowrap="">
\t \t \t \t \t <input type="checkbox" onclick="Region.selectRow(this);" value="234" name=".select" title="Select/unselect row"/>
\t \t \t \t \t <span style="display: inline-block; width: 16px; height: 10px;"/>
\t \t \t \t </td>
\t \t \t \t <td id="ext-gen11" align="left">
\t \t \t \t \t <a href="/key/module/essays/direct.view?runId=234">Study1_AS_06-20-16_1.xml</a>
\t \t \t \t </td>
\t \t \t </tr>
\t \t </tbody>
\t </table>
</form>
Dies ist die XPATH, die ich
//form[@id='Runs3']//a[text()='Study1_AS_06-20-16_1.xml']/preceding-sibling:://input[@name='.select']