java - Selenium webdriver - clicking on checkbox based on table value -


i working java/selenium webdriver automation. stuck @ particular part unable make webdriver click on checkbox based on value.

driver.findelement(by.xpath("//input[@class='chkpopupcod']/following::td[contains(text(),'bbb')]")).click();

it works when did not use axes part of xpath, can select first checkbox

below snippet of html

<tr class="even"> <td style="width: 20px;"> <input class="chkpopupcod" type="checkbox">coddata=object { id=101914, codid=101906, label="aaa", more...} </td> <td class="" align="left">aaa</td> </tr> <tr class="odd"> <td style="width: 20px;"> <input class="chkpopupcod" type="checkbox" style="background-color: rgb(255, 255, 255);">coddata=object { id=101918, codid=101907, label="bbb", more...} </td> <td class="" align="left" style="background-color: transparent;">bbb</td> </tr> <tr class="even"> <td style="width: 20px;"> <input class="chkpopupcod" type="checkbox">coddata=object { id=101922, codid=101908,   label="ccc", more...} </td> <td class="" align="left">ccc</td> </tr> 

you have right idea in xpath. flip around:

//td[contains(text(),'bbb')]/preceding::td/input[@class='chkpopupcod'] 

as in, element has text inside first. make way through tree after that.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -