Take the 2-minute tour ×

I am using RSpec and Capybara for Ruby on Rails testing.

My Rails app is localized for a number of different languages (English, German, etc.).

For example, I would like Capybara to submit a form but obviously can't use its value to select it because the value changes depending on the language that has been chosen.

This won't work in my case:

click_button("Create my account")

Is there any way to simply select the first input[type="submit"] element on the page with Capybara?

Thanks for any help.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

You can assign an id to the button and click it


Source: http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions#click_button-instance_method

share|improve this answer
Thanks. I ended up using this solution. –  Tintin81 Feb 22 '13 at 23:38

I'd say:


but give it a class or an id, it's much more safe.

share|improve this answer
Thanks. I couldn't get this to work though and ended up using an id. –  Tintin81 Feb 22 '13 at 23:37
@Tintin81 the working version is actually find('input[type="submit"]').click or alternatively using the same approach as above all('input[type="submit"]').first.click –  luopio Jul 9 at 17:06

Simple way:

share|improve this answer

Your Answer


