0
votes

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>
1
Your html stops where it becomes intressting ;)CAFEBABE
Sorry, I'm still trying to get the hang of this. I am not sure how to post the HTML code so it shows up. Let me try it here:<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>Ruby
I just did it for you as edit. You basically need to mark the HTML code and press ctrl+k. Or indent each line individually using 4 (additional) spaces.CAFEBABE

1 Answers

0
votes

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