python - I am trying to find xpath for checkbox in a table column -


i trying find xpath checkbox , click using python webdriver script. checkbox in column in table. text checkbox in column. text dm. want click checkbox has text value dm. don't want checkbox has text value ceb07_14_1504_06_52

i need xpath please.

the html is:

    <table cellspacing="0" style="table-layout: fixed; width: 100%;"> <colgroup> <tbody>     <tr class="gat4pnufg" __gwt_subrow="0" __gwt_row="0">     <td class="gat4pnueg gat4pnugg gat4pnuhg">     <div __gwt_cell="cell-gwt-uid-139" style="outline-style:none;" tabindex="0">         <input type="checkbox" tabindex="-1"/>     </div>     </td>     <td class="gat4pnueg gat4pnugg">     <div __gwt_cell="cell-gwt-uid-140" style="outline-style:none;">         <span class="linkhover" title="ceb07_14_1504_06_52" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00a;cursor:pointer;">ceb07_14_1504_06_52</span>     </div>     </td>     <td class="gat4pnueg gat4pnugg">     <div __gwt_cell="cell-gwt-uid-141" style="outline-style:none;">         <span class="" title="selenium webdriver added datamap" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;">selenium webdriver added datamap</span>     </div>     </td>     <td class="gat4pnueg gat4pnugg gat4pnubh">     <div __gwt_cell="cell-gwt-uid-142" style="outline-style:none;">         <span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;padding-right: 1px;"/>     </div>     </td>     </tr>     <tr class="gat4pnueh gat4pnumg" __gwt_subrow="0" __gwt_row="1">     <td class="gat4pnueg gat4pnufh gat4pnuhg gat4pnung">     <div __gwt_cell="cell-gwt-uid-139" style="outline-style:none;">         <input type="checkbox" tabindex="-1"/>     </div>     </td>     <td class="gat4pnueg gat4pnufh gat4pnung">     <div __gwt_cell="cell-gwt-uid-140" style="outline-style:none;">         <span class="linkhover" title="dm" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;color:#00a;cursor:pointer;">dm</span>     </div>     </td>     <td class="gat4pnueg gat4pnufh gat4pnung">     <td class="gat4pnueg gat4pnufh gat4pnubh gat4pnung"> </tr> </tbody> </table> 

i have tried //input[@type="checkbox" , tabindex="-1"] have tried //input[@type="checkbox"] no because table grow data added.

i have tried:

datamaps_checkbox_element = self.driver.find_element(by.xpath, 'html/body/div[2]/div[2]/div/div[4]/div/div[2]/div/div[3]/div/div[5]/div/div[3]/div/div[4]/div/div[2]/div/div[4]/div/div[3]/div/div[2]/div/div/table/tbody/tr/td[1]/div/input') datamaps_checkbox_element.click() 

regards, riaz

you have errors html:

line 39: "td" tags must closed line 41: must close "colgroup" 

btw:

content="//span[text()='dm']/../../..//input"             try:                             webdriverwait(self.driver, 10).until(lambda s: s.find_element_by_xpath(content).is_displayed())          except timeouterror:             logging.fatal("timeout occurred trying search content["+content+"]") self.driver.find_element_by_xpath(content).click() 

the try/except block needed if have more 1 "find_element_by_*" in code

regards claudio


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -