Azher
Azher

Reputation: 493

Unable to get "true condition" on a found element in a select list and select it

I'm using Watir 6 with Rspec and i'm having trouble accessing a select list and selecting one of the options.

The URL is: https://www.fundingcircle.com/businesses/apply?video=true

The code in question which is failing is:

browser.select_list(name: 'loan_product').select('Working capital')

HTML:

<select name="loan_product" required="" ng-model="prequal.borrower.loan_product" ng-options="product as product.label for product in prequal.loanProducts" styled-select="" placeholder="Please select..." fc-input="" class="ng-scope ng-pristine ng-invalid ng-invalid-required fc-touched">
<option value="?" selected="selected" label=""></option><option value="0" label="Working capital">Working capital</option><option value="1" label="Expansion/growth">Expansion/growth</option><option value="2" label="Refinancing a loan">Refinancing a loan</option><option value="3" label="Asset finance">Asset finance</option><option value="4" label="Tax payment">Tax payment</option><option value="5" label="Commercial mortgage">Commercial mortgage</option><option value="6" label="Other">Other</option></select>

The error I keep on receiving regardless of how many times I have tried changing the code is:

This code has slept for the duration of the default timeout waiting for an Element to be present. If the test is still passing, consider using Element#exists? instead of rescuing UnknownObjectException
Watir::Exception::UnknownObjectException: element located, but timed out after 30 seconds, waiting for true condition on {:name=>"loan_product", :tag_name=>"select"}
from /Users/.rvm/gems/ruby-2.2.2/gems/watir-6.0.2/lib/watir/elements/element.rb:528:in `rescue in wait_for_present'

The elements exist and all select list options show as true, but unfortunately they don't seem to be visible or present according to the test. Last option I feel is to manipulate the javascript, but I don't want to go down this route if I can help it. I would really appreciate it if someone could put me on the right path and advise how I can get past this issue. Any help would be much appreciated.

Upvotes: 0

Views: 1658

Answers (1)

titusfortner
titusfortner

Reputation: 4194

This is a weird one. On my mac the select list shows as visible in Firefox, but not in Chrome. Watir checks for select list to be visible before trying to click on the option. The option element is implemented in Selenium so that it will always return as visible.

So this will work for you:

browser.option(label: 'Working capital').click

I'm not sure why they are different, or what the issue is on Windows vs Chrome. Presumably chromedriver is using the same isDisplayed javascript code as geckodriver. You could probably raise this as a chromedriver bug.

Upvotes: 2

Related Questions