lundi 27 juin 2016

How to check the checkboxes using the Selenium Java WebDriver?

I was trying to figure out a way to check the checkboxes in the table grid. Usually they are defined as type='checkbox'. So I'm finding it difficult to implement using the webDriver to check the checkboxes since they are in the tags.

A sample HTML code is given below.

<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>

I tried using 'contains' in the xpath

driver.findElement(By.xpath("//*[contains(@id, 'Study1_HS.xml')]/td[1]/div/div")).click();




Aucun commentaire:

Enregistrer un commentaire