Reputation: 8965
I have the following html
<table id="registration">
<tbody>
<tr>
<td class="registration-label"><span class="size13">Password</span>
</td>
<td>
</td>
<td class="form">
<input autocomplete="off" class="title wide-input" name="icgdtval" value="" size="50" maxlength="50" type="password"/>
</td>
</tr>
<tr>
<td class="registration-label"><span class="size13">Email</span></td>
<td></td>
<td><input class="title wide-input" name="hkogplva" value="" maxlength="150" size="26" type="text"/></td>
</tr>
<tr>
<td class="registration-label"><span class="size13">Confirm Email</span></td>
<td></td>
<td><input class="title wide-input" name="EmailB" value="" size="26" maxlength="150" type="text"/></td>
</tr>
</tbody>
</table>
The rendered version looks like this
I'm trying to construct a xpath that uses the text before the text box to match the text box.
For example: Construct an xpath that would find the input tag in front of Email
by using Email
as a reference. I can not find the text box itself as the id or name are dynamically generated.
I have constructed this xpath which works, but I have failed making it work with using the text before the textbox
//tr[td][3]/td[contains(@class,'registration-label')]/following-sibling::td[2]
Upvotes: 1
Views: 284
Reputation: 52665
You can try to use following
instead of following-sibling
:
//td[.="Password"]/following::input
//td[.="Email"]/following::input
//td[.="Confirm Email"]/following::input
Or if you still want to use following-sibling
:
//td[.="Password"]/following-sibling::td/input
//td[.="Email"]/following-sibling::td/input
//td[.="Confirm Email"]/following-sibling::td/input
Upvotes: 1