I am working with rails 3 and currently writing test with capybara using selenium driver, I have issue as below
In one form i have 3 button named "save and add another", "save and continue editing" and "Save" Now, if i try to save form by capybara as below
click_button 'Save'
Then this throws error called 'Save' button with id,title or value not found Now if i remove the above 2 buttons and then i try that then it works
FYI, My 3 button's html as below,
<input class="btn" type="submit" value="Save and add another" name="_addanother" data-disable-with="Save and add another">
<input class="btn" type="submit" value="Save and continue editing" name="_continue" data-disable-with="Save and continue editing">
<input class="btn" type="submit" value="Save" name="_save" data-disable-with="Save">
Please let me know if anyone has an idea.
Method: Capybara::Node::Actions#click_button Finds a button on the page and clicks it. This can be any <input> element of type submit, reset, image, button or it can be a <button> element. All buttons can be found by their id, name, test_id attribute, value, or title.
What is Capybara? Capybara is an acceptance test framework for web applications. It's a common choice for end-to-end, acceptance, or integration testing in Rails applications. It allows developers to simulate a user on a web page and make assertions based on the content and environment of the page.
I think the problem is that all the values return a match because they all contain 'Save'.
Try assigning each one a distinctive id and using that instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With