I have a test using Cucumber, capybara and selenium driver. This test should go to a form and submit it. The normal text would be
Scenario: Fill form
Give
This is a bit hackish, but it filled a need. I monkey-patched Capybara to support a #submit method on elements.
It is not robust because it naively creates the POST parameters from every input elements's name and value attributes. (In my case, all my elements were of type hidden, so it works fine).
class Capybara::Node::Element
# If self is a form element, submit the form by building a
# parameters from all 'input' tags within this form.
def submit
raise "Can only submit form, not #{tag_name}" unless tag_name =~ /form/i
method = self['method'].to_sym
url = self['action']
params = all(:css, 'input').reduce({}) do |acc, input|
acc.store(input['name'], input['value'])
acc
end
session.driver.submit(method, url, params)
end
end
...
form = find('#my_form_with_no_submit_button')
form.submit