shockwave shockwave - 1 year ago 224
HTML Question

Select a checkbox based on a column value using XPath

I'm using selenium to automate the testing. I'm facing an issue with selecting the checkbox of a table row. So I'm using XPath to do this. I have to select the row based on the file name. Below is the HTML


<form id="Runs3" action="" method="post">
<table id="data_Runs1" class="project-data project-show-borders project-has-col-totals">
<tr class="project-alternate-row">
<td id="ext-gen3" class="project-selectors" nowrap="">
<input type="checkbox" onclick="Region.selectRow(this);" value="234" name=".select" title="Select/unselect row"/>
<span style="display: inline-block; width: 16px; height: 10px;"/>
<td id="ext-gen11" align="left">
<a href="/key/module/essays/direct.view?runId=234">Study1_AS_06-20-16_1.xml</a>

This is the XPATH that I tried


Answer Source

a is not a sibling to the desired input. Use preceding axis instead:

//a[. = 'Study1_AS_06-20-16_1.xml']/preceding::input
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download