Take the 2-minute tour ×

Till now all our tests were passing but since a week we see some problems with the facebook login test we wrote, here are the steps that we use to login with facebook :

When /^I login to facebook$/ do
  browser = page.driver.browser
  fill_in "email", :with => @facebook_test_user["email"]
  fill_in "pass", :with => @facebook_test_user["password"]
  click_button "Connection"

Now this test was passing fine because we all have facebook in French so the text of the button was Connection, but now also people that use other language for Facebook are running the tests and there it fails. Here is how the layout of the facebook button looks :

<div id="login_button_inline">
  <label for="u2krk0_2" id="loginbutton" class="uiButton uiButtonConfirm uiButtonLarge">
    <input type="submit" id="u2krk0_2" name="login" value="Connection">

The id changes constantly so using the id is not an option, how can I click on the button without taking care of the language of Facebook so that my tests are passing fine?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I'd say the name of the button - 'login' would be a good thing to find it with. Capybara's click_button method can only find buttons by id, text or value, so you'll have to find it yourself:

find(:css, "input[name='login']").click

You may need to restrict the scope if you have other 'login' buttons elsewhere on the page, but if not this should work for you.

share|improve this answer

Your Answer


