Reputation: 3
I am new to cucumber and HTML. In my test I try to click on the "Check Inventory" button using -> click_button('Check Inventory') or click_on('Check Inventory'). I get this error:
no button with value or id or text 'Check Inventory' found (Capybara::ElementNotFound)
I have been able to successfully test clicking buttons with name or value tags. So I am not sure if the title tag behaves differently. Here's the HTML:
<div id="inventory">
<h4 class="border_bottom">Inventory</h4>
<div><div class="check-inventory-btn btn-blue" title="Check Inventory">Available Inventory</div><label for="some stuff"><input id="some stuff" name="some stuff" type="checkbox" value="1">Some stuff here</label></div>
...
...
</div>
Upvotes: 0
Views: 1549
Reputation: 49870
click_button in Capybara finds input elements (of type submit, reset, image, button or image), and button elements. Your "button" is none of those, but rather a div styled to look like a button. To click on that you'll need to find the element (by css selector, etc) and call click on it. In this case something along the lines of
find(:css, 'div[title="Check Inventory"]').click
should do what you want
Upvotes: 1