Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RackTest extension for submitting a form without a button #529

wants to merge 1 commit into from


Copy link

@ozeias ozeias commented Oct 21, 2011

based on that gist

Copy link

@jnicklas jnicklas commented Oct 21, 2011

I've previously been asked for this feature and have repeatedly denied it. Just add a submit button to your form. Some browsers will not submit forms without submit buttons even on pressing enter, so it's good practice anyway.

@jnicklas jnicklas closed this Oct 21, 2011
Copy link

@marcandre marcandre commented Nov 19, 2011

Please add my name to the list of people requesting this feature.

BTW, I welcome tools that encourage good practices but I would respectfully disagree when they force these practices down everybody's throat.

It unwise to assume that all webapps are designed to be used by everybody or to be compatible with all browsers; in some cases, webapps may fall outside the norm, can be specialised for a very few specific users or to run only on a small set of chosen browsers.


Copy link

@jnicklas jnicklas commented Nov 19, 2011

Well, the problem is that we can't implement it in any meaningful way. It's illogical to expect all drivers to implement something which does not work in many browsers. Conceptually it just doesn't make sense. What kind of user action is "submit_form" equivalent to? Hitting enter? What if the user has attached a keydown event handler to this form? It just doesn't make any sense.

Just add the damn button, hide it if you need to (though you probably really shouldn't) and be done with it. It'd be much more interesting to add a send_keys method, and we have had discussions to that effect, but again, the problem was cross-driver compatibility.

Copy link

@marcandre marcandre commented Nov 19, 2011

Thanks for the reply; I understand better the objection.

Indeed, a "press enter" / "send keys" would be more appropriate, at least for javascript capable drivers. I imagine this is already possible with an execute_script.

So maybe submit_form could be defined as firing off an enter key event for drivers that can do this, and simply submitting the form for others that can't?


Copy link

@jacobo jacobo commented Oct 25, 2013

My use case is testing an implementation of heroku Add-ons SSO. My page contents look something like this:

<form method="POST" action="https://XXXXXXXX/sso/login">
    <input type="hidden" name="token" value="XXXXXXX" />
<script type="text/javascript">

If I were using a backend more advanced than rack:test then I wouldn't have to submit the form. But in this case I see no other choice but to monkey patch Capybara. Adding a submit button would make it appear to the user. I suppose I could render a submit button only in test, but that feels like a worse Hack, no?

Monkey Patch Capybara

  #Hax for browser with javascript auto-following the POST redirect
  form = page.find("form")
  class << form
    def submit!, native).submit({})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants