Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

possible to select multiple options with xpath?

Tags:

xpath

nokogiri

/html/body/form/select/option[@val = '1' and @val = '3']

so that means select the first and third option in a select-multiple form ?

like image 816
h34y Avatar asked Oct 10 '09 20:10

h34y


People also ask

How do you locate multiple elements with the same XPath?

If an xpath refers multiple elements on the DOM, It should be surrounded by brackets first () and then use numbering. if the xpath refers 4 elements in DOM and you need 3rd element then working xpath is (common xpath)[3].

How can we move to nth child element using XPath?

By adding square brackets with index. By using position () method in xpath.


1 Answers

Did you mean or?

/html/body/form/select/option[@val = '1' or @val = '3']

That should select both elements. By using and you're trying to select an element whose val is both 1 and 3, which isn't going to work. :-)

like image 193
RichieHindle Avatar answered Sep 23 '22 05:09

RichieHindle