Method: Splinter::Capybara::Actions#complete_form
- Defined in:
- lib/splinter/capybara/actions.rb
#complete_form(base) {|form = FormCompleter.new(base, self)| ... } ⇒ Object
Complete and submit a form
base - The name of the form, (eg: :post for form_for @post)
A required block is yielded to a FormCompleter object. The form will be completed and submitted upon execution of the block.
Example:
complete_form :post do |f|
f.text_field :author, "Joshua Priddle"
f.text_area :bio, "Lorem ipsum"
f.checkbox :admin, true
f.select :group, 'admins'
f.radio :autosave, false
f.date :publish_at, Time.now
f.datetime :publish_at, Time.now
t.time :publish_at, Time.now
end
You can also manually submit in case your submit input field requires a custom selector:
complete_form :post do |f|
...
f.submit "//custom/xpath/selector"
end
54 55 56 57 |
# File 'lib/splinter/capybara/actions.rb', line 54 def complete_form(base) yield form = FormCompleter.new(base, self) form.submit unless form.submitted? end |