How To Select Checkbox

I am having trouble selecting and checking the second input checkbox in the screen below using xPath.

The html code for the checkbox I am trying to select is below.

The html code for the table holding the checkbox is below.

                    <table id='encounterTable' class="table table-condensed table-striped table-hover">
                        <thead>
                            <tr>
                                <th border="1">
                                    
                                        <span title="Select/Unselect All Encounters">
                                            <input type="checkBox" id="selectAll" name="selectAll" onchange="javascript: toggleSelectAllFunction();" style="vertical-align: top;" />
                                        </span>
                                    
                                </th>

                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=encounterNumber&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Encounter Number</a>

                                </th>

                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=dateOfService&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Encounter Date</a>
                                </th>

                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=patientCode&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Patient No.</a>
                                </th>

                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=lastName&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Patient Name</a>
                                </th>

                                <th>
                                    
                                    <a href="/Proteus/batch/listNew?sort=appointmentProvider&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Appointment Provider</a>
                                    
                                </th>

                                <th>
                                    
                                    <a href="/Proteus/batch/listNew?sort=billingProvider&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Billing Provider</a>
                                    
                                </th>

                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=location&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Location</a>
                                </th>

                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=modifiedDate&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Modified Date</a>

                                </th>

                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=modifiedByUser&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Modified By</a>

                                </th>

                               
                                <th onclick="cursorWait()">
                                    <a href="/Proteus/batch/listNew?sort=appointmentExists&amp;&amp;&amp;unreconciledEncounters=false&amp;&amp;restrictApptDate=true&amp;&amp;isSort=true">Appointment Exists</a>
                                </th>


                            </tr>
                        </thead>
                        <tbody>
                            
                                <tr id="encounterRow0" class="odd">
                                    
                                    <script type="text/javascript">

                                        selectedCheckboxValues[0] = "4929F78D-CE33-4529-9EA1-9E901B9A60F5";
                                    <td>
                                        <input type="hidden" name="_selected-0" /><input type="checkbox" name="selected-0" value="4929F78D-CE33-4529-9EA1-9E901B9A60F5" id="selected-0"  />
                                    </td>
                                    <td><div class="list_entry">PT7884512-04083947-8744</div></td>
                                    <td><div class="list_entry"><NOBR>05/04/2020</NOBR></div></td>
                                    <td><div class="list_entry">
                                        
                                            7884512
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                            DON MARTIN
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                            MANUEL ELYAS CHAENY DMD
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                    </div></td>
                                    <td><div class="list_entry"><NOBR>05/04/2020 07:40</NOBR></div></td>
                                    <td><div class="list_entry">GM</div></td>
                                    <td align="center"><div class="list_entry" align="center">
                                        
                                            false
                                        
                                    </span></div></td>

                                </tr>
                            
                                <tr id="encounterRow1" class="even">
                                    
                                    <script type="text/javascript">

                                        selectedCheckboxValues[1] = "5E46F2F1-EB0A-4E70-808B-C641ED5E57EB";
                                    <td>
                                        <input type="hidden" name="_selected-1" /><input type="checkbox" name="selected-1" value="5E46F2F1-EB0A-4E70-808B-C641ED5E57EB" id="selected-1"  />
                                    </td>
                                    <td><div class="list_entry">PTams2019-04083850-9134</div></td>
                                    <td><div class="list_entry"><NOBR>05/04/2020</NOBR></div></td>
                                    <td><div class="list_entry">
                                        
                                            ams2019
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                            ANDREA SMITH
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                            MANUEL ELYAS CHAENY DMD
                                        
                                    </div></td>
                                    <td><div class="list_entry">
                                        
                                    </div></td>
                                    <td><div class="list_entry"><NOBR>05/04/2020 07:39</NOBR></div></td>
                                    <td><div class="list_entry">GM</div></td>
                                    <td align="center"><div class="list_entry" align="center">
                                        
                                            false
                                        
                                    </span></div></td>

                                </tr>
                            
                        </tbody>
                    </table>

Thank You

1 Like

I found the solution. Thank you anyway.

1 Like

Please post the solution (or invite me to remove the topic?)

The solution that worked for me was;

WebDriver driver = DriverFactory.getWebDriver()

IWebElement element = driver.findElement(By.xpath("//input[@type=‘checkbox’ and contains(@value,‘5E46F2F1-EB0A-4E70-808B-C641ED5E57EB’)]")).click();

1 Like