I'm using Capybara 2.2.1 with Rspec.
I have this code on my page:
<select id="question_category_id" name="question[category_id]">
And I've tried each of these:
select "General", from: "question_category_id"
select "General", from: "question[category_id]"
select "General", from: "Category"
page.select "General", from: "Category"
I get the same error every time:
Failure/Error: select "General", from: "Category"
Unable to find option "General"
Everything I've read says that all of these should work. Am I doing something wrong?
I would guess that your option elements are being hidden through css or something along those lines. You can verify this by doing
select "General", from: "Category", visible: false
Also this question is better asked on the mailing list
One other possibility is you have multiple selects and have set Capybara.match = :first - although I don't think thats it since you have tried every different locator format for it, and you would have had to have multiple selects with the same id to keep seeing the issue
Thanks for the response. The select is definitely visible, but I tried visible: false just as a sanity check -- no dice. This is also the only select in the form, so that can't be it either.
I'll ask on the mailing list. Thanks.
I have the exact same problem with 2.2.1, and it was working perfectly before with 2.0.2. All my specs with a select failed now. @kiddrew where you able to fix that on our side?
I did get it working, but I can't remember at this point what I did...
select X, from: Y
X should be an option label, not an option value
That also happens when using Materializecss (with js: true), in that case is enough to pass the visible: false option (thanks @twalpole)
I just spent an afternoon on this issue, when doing a bit of debugging noticed that some of the fields were empty on the form, which led me to clone the development DB.