I have the following html fragment.
<select id="priority1" class="selectPriority form-control">
<option value="/ABCD" selected="selected">
10 Parameter x100
</option>
<option value="DEF">
10 Parameter x150
</option>
</select>
Using the below CSS selector to select all the option tag fails
find_all(S("#priority1 > option"))
However this works
[
options.web_element.find_elements_by_tag_name("option")
for options in find_all(S("#priority1"))
]
I am unable to understand this weird behavior can anyone please explain as whats going on
As per the documentation in CSS Selector Reference
So
find_all(S("#priority1 > option"))
would select all the<option>
elements where the parent element'sid
attribute value is#priority1
. Hence instead of selecting all the<option>
elements, it would select only one.Solution
To select all the
<option>
tags you need to use: