テーブルグリッドのチェックボックスをチェックする方法を見つけようとしていました。通常、これらはtype = 'checkbox'として定義されます。そのため、チェックボックスはタグ内にあるため、webDriverを使用してチェックボックスをチェックすることを実装するのは難しいと感じています。
サンプルのHTMLコードを以下に示します。
<tbody id="gridview-2345-body">
<tr id="gridview-2345-record-/DNA/Study1_HS.xml" class="x4-grid-row x4-grid-data-row x4-grid-row-selected" data-boundview="gridview-1270" role="row">
<td id="ext4-ext-gen1234" class="x4-grid-cell x4-grid-td" role="gridcell">
<div class="x4-grid-cell-inner " style="text-align:left;" unselectable="on">
<div class="x4-grid-row-checker"/>
</div>
</td>
<td id="ext4-ext-1235" class="x4-grid-cell x4-grid-td" role="gridcell">
<div class="x4-grid-cell-inner " style="text-align:left;" unselectable="on">
<span id="ext4-icon1568" class="fa fa-file-code-o labkey-file-icon"/>
</div>
</td>
<td id="ext4-ext-gen1236" class="x4-grid-cell x4-grid-td" role="gridcell">
<div class="x4-grid-cell-inner " style="text-align:left;" unselectable="on">
<div width="100%" height="16px">
<div style="float: left;"/>
<div style="padding-left: 8px; white-space:normal !important;">
<span style="display: inline-block; white-space: nowrap;">Study1_HS.xml</span>
</div>
</div>
</div>
</td>
</tr>
</tbody>
xpathで「contains」を使用してみました
driver.findElement(By.xpath("//*[contains(@id, 'Study1_HS.xml')]/td[1]/div/div")).click();
そのため、xpathで「preceding」を使用して機能させました
//span[text()='Study1_HS.xml']/preceding::td/div/div[@class='x4-grid-row-checker']
http://www.xpathtester.com/xpath/b1d50008dd4be8ab7545548c4b8238f5
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加