A
A
Andrey Belokopytov2016-04-30 17:09:16
Ruby on Rails
Andrey Belokopytov, 2016-04-30 17:09:16

Capybara: why doesn't the :visible option work?

Please help me figure out why Capybara always finds the email field regardless of the visible value.
There is a page with the following field on the form:

<label>
  <input type="email" name="email" class="hide" placeholder="Email">
</label>

This is the .hide class
.hide {
    display: none !important;
}

When I test a page with Capybara with the Poltergeist driver, I do a very simple test:
<br>
page.must_have_field('email', :type => 'email', :visible => false)<br>
check('Send by email')<br>
page.must_have_field('email', :type => 'email', :visible => true)<br>

So the test passes, despite the fact that there is no code for switching the visibility of the field, i.e. it is always hidden.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Belokopytov, 2016-04-30
@belokopytoff

The error was that I configured the driver for Capybara incorrectly.
Instead
of Capybara.default_driver = :poltergeist
I had
Capybara.javascript_driver = :poltergeist
I learned that I was working with a default driver that doesn't look for hidden elements correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question