Last active
May 7, 2020 11:30
-
-
Save marcoslebron/ca96949c7ea9bd45d82ea4afe0e4141e to your computer and use it in GitHub Desktop.
I was trying to submit a form without button using just Capybara and Rspec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Capybara::Session | |
def submit(element) | |
Capybara::RackTest::Form.new(driver, element.native).submit({}) | |
end | |
end | |
#in the test | |
fill_in 'Search', with: 'dice' | |
form = find '#search-form' # find the form | |
page.submit form # use the new .submit method, pass form as the argument |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is awesome! I looked at both suggestions. Thanks!
I already have
in my
spec/rails_helper.rb
for other reasons, so I created a new filespec/support/submit_form.rb
:Now my tests allow me to call things like: