Reputation: 756
I have a table that looks like this:
<table>
<thead>
<tr>
<th data-th-key="col1"> <span> Foo </span> </th>
<th data-th-key="col2"> <span> Bar </span> </th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div>
<input data-model-key="col1">
</div>
</td>
<td>
<div>
<input data-model-key="col2">
</div>
</td>
</tr>
</tbody>
</table>
To find the right input element I have to know the data-th-key from the table head. Is there any way to use the first xpath inside the second one?
Xpath one:
//table//thead//span[translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='foo']/parent::th/@data-th-key"
Xpath two:
//table//tbody//tr//td//div//input[@data-model-key='col1']
So I want to replace the col1 value in the second one with Xpath one.
Upvotes: 1
Views: 63
Reputation: 167716
You can write an expression like
//table//tbody//tr//td//div//input[@data-model-key = //table//thead//span[translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='foo']/parent::th/@data-th-key]
yes, that is possible and meaningful and selects the input (or the inputs) whose data-model-key
is equal to that data-th-key
attribute.
Upvotes: 3