firebug - How to select the first selement from the sequence returned by Xpath -
i'm trying find specific web-element: input field belongs class "selectdatetime" , located next label "from". xpath query
//fieldset[legend="pickup"]//div[@class="selectdatetime"]
founds element, 1 element of same class presents on page. tried select first or last element using following xpath query
//fieldset[legend="pickup"]//div[@class="selectdatetime"][1] (//fieldset[legend="pickup"]//div[@class="selectdatetime"])[1]
but in 1st case query founds 2 elements, in second case query doesn't produce result. know, how can resolve problem? may be, have work-around? you're welcome ideas.
here xml parsed:
[fieldset] [legend] pickup [/legend] [div class="block block_position_first"] [div class="tr"] [div class="td"] [label] from: [/label] [/div] [div class="td"] [div class="selectdatetime"] [input class="date" type="text" placeholder="dd/mm/yyyy"/] [input class="time" type="text" placeholder="00:00"/] [/div] [/div] [/div] [div class="tr"] [div class="td"] [label] to: [/label] [/div] [div class="td"] [div class="selectdatetime"] [input class="date" type="text" placeholder="dd/mm/yyyy"/] [input class="time" type="text" placeholder="00:00"/] [/div] [/div] [/div] [/div] [/fieldset]
there problems posting xml-file, i've replace < , > [ , ] respectively
use [1]
first element , [last()]
last one. make sure add appropriate parentheses, otherwise receive first or last element of each run last step expression.
(//fieldset[legend="pickup"]//div[@class="selectdatetime"])[1] (//fieldset[legend="pickup"]//div[@class="selectdatetime"])[last()]
Comments
Post a Comment