ve ar
ve ar

Reputation: 15

Why Capybara cant find css?

I try to write simple feature spec, but I dont understand Capybara behavior. So, I have that code:

> parent.class
=> Capybara::Node::Element
> parent.find(:css, 'button.remove-arrow')
=> Capybara::ElementNotFound: Unable to find css "button.remove-arrow"
from /Users/weare138/.rvm/gems/ruby-2.3.3/gems/capybara-2.11.0/lib/capybara/node/finders.rb:44:in `block in find'

but when i try to do call via web-driver:

> parent.native.find(:css, 'button.remove-arrow')

it return me right answer

=> [#<Capybara::Poltergeist::Node tag="button" path="//HTML[1]/BODY[1]/DIV[1]/SECTION[1]/DIV[1]/FORM[1]/DIV[2]/DIV[2]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/BUTTON[1]">]

what I do wrong?

Upvotes: 0

Views: 890

Answers (1)

Thomas Walpole
Thomas Walpole

Reputation: 49880

The most likely reason is that the node isn't actually visible on the page, which Capybara takes into account, but the driver doesn't. If

parent.find(:css, 'button.remove-arrow', visible: :false)

finds the element it would confirm that visibility is indeed the difference. If not then the actual HTML/CSS would be needed to know why.

Upvotes: 3

Related Questions