In Cucumber, with Rspec and Capybara I have a test to check that a button has a class. Here it is
expect(@some_button).to have_css(".in-cart")
it fails, but
@some_button['class']
returns
'btn product in-cart'
so the button definitely has the 'in-cart' class.
As a temporary measure I've changed my test to be;-
expect(@some_button['class']).to match /in-cart/
Which is obviously insane. But why should 'have_css', or 'has_css?' return false for a DOM element that clearly has the expected class?
Also page.all('.in-cart') includes the button, so Capybara can definitely find it.
Incidentally I also tried 'button.in-cart', 'in-cart',expect (etc).to have_selector, expect(etc.has_selector?('.in-cart')).to be_truthy and all combinations.
expect(@some_button).to have_css("btn.product.in-cart")
– Richlewis