Reputation: 2389
I don't even know how to describe this :)
I have bunch of div
s, with similar IDs that have random part added to each (the random part is different for each session). and deeply nested in one of them a bunch of radio input boxes, without anything I can tie to (also the whole tree under the div
doesn't have unique attributes I can tie to).
I need the first radio button. I get the needed div with (//div[contains(@id,'div-question')])[2]
, and I thought I could follow it up with similar construct, but I can't figure out how. I Also tired following:
(//div[contains(@id,'div-question')])[2]//input[@type='radio' and position() = 1]
but it return me all radio buttons, not only the first one (I'm using FirePath from FireBug -- could it be it's bug?)
So, how do I join two //...
searches?
Upvotes: 0
Views: 34
Reputation: 163458
//x[position()=1]
returns every descendant x that is the first child of its parent. To select the first descendant x, you need (//x)[position()=1]
. With a complex path it becomes easier to use the descendant axis explicitly rather than the //
shorthand:
descendant::div[contains(@id,'div-question')][2]
/descendant::input[@type='radio'][1]
Upvotes: 3