N
N
Nikita Filatov2016-03-28 18:04:47
Ruby on Rails
Nikita Filatov, 2016-03-28 18:04:47

Why does Capybara not see the option on the page?

When trying to use the select method, Capybara throws the following error:

Unable to find option "Back-End" (Capybara::ElementNotFound)

Although this element is present on the page.
There is such a code using Capybara I need to select one of the options in the select: So this option is implemented:
select 'Back-End', :from => 'product_category_id'
<%= f.select :category_id, Category.all.collect { |c| [ c.name, c.id ] } %>

And this is how it looks on the page:
<select name="product[category_id]" id="product_category_id">
<option value="1">Back-End</option>
<option value="2">Front-End</option>
</select>

I tried to put in the first field not the Back-End itself, but value.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene Burmakin, 2016-03-28
@M0NSTERC4T

Maybe because it is not there in the test environment? try `save_and_open_page` and make sure the desired option exists.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question