Submitting a form without a button using Capybara
Code below is based on this gist and this pull request.
Only tested in Capybara 1.3 and solely works when using the Rack test driver.
## Load code after Capybara class Capybara::Driver::Node def submit_form! raise NotImplementedError end end class Capybara::RackTest::Node def submit_form! Capybara::RackTest::Form.new(driver, self.native).submit({}) end end class Capybara::Node::Element def submit_form! wait_until { base.submit_form! } end end
Usage:
You must enter in the form element itself as a selector e.g.:
find('#form-element-id').submit_form! find('form').submit_form! all('form').last.submit_form!
- Pushed on 04/11/2013 by Christian