I am trying to select an option from a select list using watir-webdriver.
watir-webdriver gem version : 0.6.4 Ruby 1.9.3 on mac osx lion
HTML of the select list:
<select id="cc.expiryMonth" name="cc.expiryMonth">
<option value="0">Month</option>
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
<option value="4">04</option>
<option value="5">05</option>
<option value="6">06</option>
<option value="7">07</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
The code i used is
@browser.select_list(:name => "cc.expiryMonth").options[4].select
I am getting error
Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotVisibleError)
[remote server] file:///var/folders/_c/j__zdvw93gqgyyvzwmmgtwwr0000gn/T/webdriver-profile20130620-1023-1s8kag6/extensions/[email protected]/components/command_processor.js:7736:in `fxdriver.preconditions.visible'
[remote server] file:///var/folders/_c/j__zdvw93gqgyyvzwmmgtwwr0000gn/T/webdriver-profile20130620-1023-1s8kag6/extensions/[email protected]/components/command_processor.js:10437:in `DelayedCommand.prototype.checkPreconditions_'
[remote server] file:///var/folders/_c/j__zdvw93gqgyyvzwmmgtwwr0000gn/T/webdriver-profile20130620-1023-1s8kag6/extensions/[email protected]/components/command_processor.js:10456:in `DelayedCommand.prototype.executeInternal_/h'
[remote server] file:///var/folders/_c/j__zdvw93gqgyyvzwmmgtwwr0000gn/T/webdriver-profile20130620-1023-1s8kag6/extensions/[email protected]/components/command_processor.js:10461:in `DelayedCommand.prototype.executeInternal_'
[remote server] file:///var/folders/_c/j__zdvw93gqgyyvzwmmgtwwr0000gn/T/webdriver-profile20130620-1023-1s8kag6/extensions/[email protected]/components/command_processor.js:10401:in `DelayedCommand.prototype.execute/<'
./features/step_definitions/Wotif_FlightSearch_DOM_steps.rb:145:in `/^I enter all details on booking page$/'
Went through the watir-webdriver code in the gem library and exhausted all ways of selecting an option, all of them throw the same error.
@browser.select_list(:name => "cc.expiryMonth").focus
is successful, but selecting option throws element not visible error. Also tried send_keys unsuccessfully. Would appreciate any suggestions on how to handle this
UPDATE:
@browser.select_list(:name => "cc.expiryMonth").options[8].value
returns the value but
@browser.select_list(:name => "cc.expiryMonth").options[8].select
or
@browser.select_list(:name => "cc.expiryMonth").select @browser.select_list(:name => "cc.expiryMonth").options[8].value returns element not found error