I’m trying to get the select list values using xpath because by id is giving me false in the exists function, but is not working
puts $browser.select_list(:xpath,"//*[@id='numType']").exists?
number = $browser.select_list(:xpath,"//*[@id='numType']").options.map(&:text)
number_list = Array.new
number.each do |number_text|
number_list << "#{number_text}"
end
HTML code:
<div id="forwardRs">
<div class="forwardR">
<div id="forwardT" class="rc1">
<select id="forward_types" name="Foward Types" tabindex="5" onchange="changeForwardTypes(this);">
<option value="unconditional">unconditional</option>
<option value="busy">busy</option>
<option value="reply">reply</option>
<option value="reachable">reachable</option>
<option value="other">other</option>
</select>
</div>
<div id="numtype" class="rc1" style="">
<select id="numType" onchange="changeNumType(this);" name="numbers" tabindex="5">
<option value="ex">Ex</option>
<option value="in">In</option>
</select>
</div>
<div id="rule" class="rc1" style="">
<input id="tel" type="text" value="" size="20" name="tel" tabindex="2" onchange="changeNumberRule(this);">
</div>
<div id="removeForwardRule" class="rc3">
<a onclick="removeForwardRule(this);">
<img src="../../images/delete.png">
</a>
How can i do this?
Tanks
Disregard what I originally wrote here, as I have been completely unsuccessful in getting the
.optionsmethod to return any of the options in a select list, whereas the.selected_optionsmethod returns the selected options just fine.I’ve been able to successfully get the options from your select list by doing the following:
which gives you an array of the options in the select list.
To get the text out of those elements I did
Not a very pretty answer but hey.
I have literally no idea why
.optionsdoes not work for me, but you may be suffering the same problem.