Eugene
Eugene

Reputation: 5533

Xpath: select an element of specific type which is sibling to the selected element

Here is an excerpt of my xml:

<div class="0001">
    <label title="Label1">Label1:</label>
</div>
<div class="0002">
    <input type="text">
</div>

I know how to select the "Label1" label. I need to select an input of text type. Class names are generated in a random way and changes after each session. So it's only possible to refer to label title and an input type

Upvotes: 0

Views: 352

Answers (1)

paul trmbrth
paul trmbrth

Reputation: 20748

Try:

'//div[label[@title="Label1"]]/following-sibling::div/input[@type="text"]'

select a <div> which contains a <label> which itself has a title attribute with value Label1, then look for an <input> with type "text" in the <div> siblings of this former <div>

Upvotes: 2

Related Questions