Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8848959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:31:38+00:00 2026-06-14T12:31:38+00:00

When i fill the form in using the code specified below (at Cucumber tests)

  • 0

When i fill the form in using the code specified below (at Cucumber tests) and submit the one, my params hash comes with totally empty at controller.

I’ve done some debugging and at some deep level of Capybara, when it does actually sending, Nokogiri nodes do not have the value attribute set whils before the click_button call they do have.

visit '/'
click_link 'Sign out' if has_link? 'Sign out'
click_link 'Log in'

find(:css, '#user_email').set 'my@email.com'
find(:css, '#user_password').set 'foobar'
find(:css, '#user_remember_me').set true

click_button 'Sign in'

My params hash at controller:

{"utf8"=>"✓", "user"=>{"email"=>"", "password"=>"", "remember_me"=>"1"}, "commit"=>"Sign in", "action"=>"create", "controller"=>"auth"}

The form HTML is something like this:

<form accept-charset="UTF-8" action="/users/sign_in" class="new_user" id="new_user" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="blah-blah-blah"></div>
<div class="email">
<label for="user_email" title="Email or LDAP username">Login</label>
:
<input autofocus="autofocus" id="user_email" name="user[email]" placeholder="EMAIL or LDAP" size="30" title="Email or LDAP username" type="text" value="">
</div>
<div class="password">
<label for="user_password">Password</label>
:
<input id="user_password" name="user[password]" placeholder="PASSWORD" size="30" type="password">
</div>
<div class="rememberable">
<label for="user_remember_me">Remember me</label>
:
<div class="checkbox">
<input name="user[remember_me]" type="hidden" value="0"><input id="user_remember_me" name="user[remember_me]" type="checkbox" value="1">
</div>
</div>
<div class="signin">
<div class="wrapper">
<div class="input">
Sign in
<input name="commit" type="submit" value="Sign in">
</div>
</div>
</div>
</form>

The output from running the cucumber features/my_feature.feature -vb:

shybovycha@shybovycha-laptop:~/projects/rails/my_project$ cucumber features/my_feature.feature -vb
Using the default profile...
Code:
  * features/support/env.rb
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
Clearing database
Running db:migrate
Running db:seed for our instance
  * features/support/capybara_headers.rb
  * features/step_definitions/backoffice.rb
  * features/step_definitions/content_verification .rb
  * features/step_definitions/db_manipulation.rb
  * features/step_definitions/forms_and_links.rb
  * features/step_definitions/jenkins_integration.rb
  * features/step_definitions/mobile_view.rb
  * features/step_definitions/navigation.rb
  * features/step_definitions/users_manipulation.rb

Features:
  * features/my_feature.feature
Parsing feature files took 0m0.135s

Feature: my_feature

  Scenario: do some actions               # features/my_feature.feature:3
    Given a logged in user                 # features/step_definitions/users_manipulation.rb:45
    And some data exists                      # features/step_definitions/db_manipulation.rb:12
    When I visit some page        # features/step_definitions/navigation.rb:13
    And click "Subscribe" link                      # features/step_definitions/forms_and_links.rb:6
      no link with title, id or text 'Subscribe' found (Capybara::ElementNotFound)
      /var/lib/gems/1.9.1/gems/capybara-1.1.3/lib/capybara/node/finders.rb:154:in `raise_find_error'
      /var/lib/gems/1.9.1/gems/capybara-1.1.3/lib/capybara/node/finders.rb:27:in `block in find'
      /var/lib/gems/1.9.1/gems/capybara-1.1.3/lib/capybara/node/base.rb:54:in `wait_until'
      /var/lib/gems/1.9.1/gems/capybara-1.1.3/lib/capybara/node/finders.rb:27:in `find'
      /var/lib/gems/1.9.1/gems/capybara-1.1.3/lib/capybara/node/actions.rb:27:in `click_link'
      (eval):2:in `click_link'
      /var/lib/gems/1.9.1/gems/capybara-1.1.3/lib/capybara/dsl.rb:161:in `click_link'
      /home/shybovycha/projects/rails/my_project/features/step_definitions/forms_and_links.rb:8:in `block in <top (required)>'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/core_ext/instance_exec.rb:48:in `instance_exec'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/core_ext/instance_exec.rb:48:in `block in cucumber_instance_exec'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/core_ext/instance_exec.rb:69:in `cucumber_run_with_backtrace_filtering'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/core_ext/instance_exec.rb:36:in `cucumber_instance_exec'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/rb_support/rb_step_definition.rb:69:in `invoke'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/step_match.rb:25:in `invoke'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/step_invocation.rb:60:in `invoke'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/step_invocation.rb:38:in `accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:99:in `block in visit_step'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:98:in `visit_step'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/step_collection.rb:15:in `block in accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/step_collection.rb:14:in `each'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/step_collection.rb:14:in `accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:93:in `block in visit_steps'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:92:in `visit_steps'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/scenario.rb:55:in `block (2 levels) in accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:80:in `block (2 levels) in with_hooks'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:96:in `before_and_after'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:79:in `block in with_hooks'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:120:in `call'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:120:in `block (3 levels) in around'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/language_support/language_methods.rb:9:in `block in around'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/language_support/language_methods.rb:91:in `call'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/language_support/language_methods.rb:91:in `execute_around'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/language_support/language_methods.rb:8:in `around'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:119:in `block (2 levels) in around'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:117:in `call'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:117:in `around'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:91:in `around'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:78:in `with_hooks'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/scenario.rb:53:in `block in accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/scenario.rb:108:in `with_visitor'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/scenario.rb:47:in `accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:51:in `block in visit_feature_element'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:50:in `visit_feature_element'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/feature.rb:43:in `block in accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/feature.rb:42:in `each'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/feature.rb:42:in `accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:20:in `block in visit_feature'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:19:in `visit_feature'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/features.rb:29:in `block in accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/features.rb:17:in `each'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/features.rb:17:in `each'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/features.rb:28:in `accept'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:14:in `block in visit_features'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:163:in `broadcast'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/ast/tree_walker.rb:13:in `visit_features'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:46:in `run!'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in `execute!'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in `execute'
      /var/lib/gems/1.9.1/gems/cucumber-1.2.1/bin/cucumber:14:in `<top (required)>'
      /usr/local/bin/cucumber:19:in `load'
      /usr/local/bin/cucumber:19:in `<main>'
      features/my_feature.feature:7:in `And click "Subscribe" link'
...

That error shall tell you nothing except the content was not found. The reason is, devise does no authentication because the params hash is empty. So it could get no user data. So it could not authenticate one. So it does not let the user to view the page and redirects him to the homepage displaying the error message. So the content the test should use is not found.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:31:40+00:00Added an answer on June 14, 2026 at 12:31 pm

    Found the solution and the reason of the issue.

    The reason

    The short version

    Somehow Capybara (even with PhantomJS) does not recognize if the element is visible or not. It’s the internals of Capybara, not my tests.

    Detailed reason description

    See, we have two forms on one page – signing up form and signing in form.
    Both are hidden but when user hits either sign in or sign up button, correspondent form is shown.
    Both forms contain fields #user_email and #user_password.
    But the sign up form contains #user_password_confirmation whilst sign in form contains #user_remember_me instead.

    Just take a look at the code of the forms:

    <div class="forms">
        <div class="signup-form" style="display: block;">
            <form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
                <div style="margin:0;padding:0;display:inline">
                    <input name="utf8" type="hidden" value="&#10003;" />
                    <input name="authenticity_token" type="hidden" value="viNleUNDfdlp92j9vVU9QravqMRbmCUZDqw3pV9jQK0=" />
                </div>
    
                <div class="email">
                    <input autofocus="autofocus" id="user_email" name="user[email]" placeholder="EMAIL or LDAP" size="30" type="email" value="" />
                </div>
    
                <div class="password">
                    <input id="user_password" name="user[password]" placeholder="PASSWORD" size="30" type="password" />
                </div>
    
                <div class="password">
                    <input id="user_password_confirmation" name="user[password_confirmation]" placeholder="PASSWORD CONFIRMATION" size="30" type="password" />
                </div>
    
                <div class="signup">
                    Sign up
                    <input name="commit" type="submit" value="Sign up" />
                </div>
            </form>
        </div>
    
        <div class="signin-form" style="display: none;">
            <form accept-charset="UTF-8" action="/users/sign_in" class="new_user" id="new_user" method="post">
                <div style="margin:0;padding:0;display:inline">
                    <input name="utf8" type="hidden" value="&#10003;" />
                    <input name="authenticity_token" type="hidden" value="viNleUNDfdlp92j9vVU9QravqMRbmCUZDqw3pV9jQK0=" />
                </div>
    
                <div class="email">
                    <input autofocus="autofocus" id="user_email" name="user[email]" placeholder="EMAIL or LDAP" size="30" title="Email or LDAP username" type="text" value="" />
                </div>
    
                <div class="password">
                    <input id="user_password" name="user[password]" placeholder="PASSWORD" size="30" type="password" />
                </div>
    
                <div class="rememberable">
                    <label for="user_remember_me">Remember me</label>:
    
                    <div class="checkbox">
                        <input name="user[remember_me]" type="hidden" value="0" />
                        <input id="user_remember_me" name="user[remember_me]" type="checkbox" value="1" />
                    </div>
                </div>
    
                <div class="signin">
                    Sign in
                    <input name="commit" type="submit" value="Sign in" />
                </div>
            </form>
        </div>
    </div>
    

    Now, at the test there is a line that should make the signing in form visible. Then test tries to fill the visible form and send it to a server.

    Yet, somewhy Capybara does not disticts the visible form and the invisible one. So it fills the inputs within the first form which is formely the sign up one.

    Then there is a code line which clicks the sign in button. See? The filled in form is the sign up and the submit one is sign in.

    The solution

    The short version

    Do not use fill_in 'Input', :with => 'value'.

    Use find(:css, '#selector').set 'value' or find(:xpath, '/selector').set 'value' instead.

    The detailed description

    As of the described reason, fill_in searches for the first visible element matching the label/id/title given (Input in my example a few lines above).

    If you may have a few inputs with the same label/id/title on one page but within different forms, the fill_in may be ambigious and fill the wrong element.

    The find method searches for the first element matching the selector rule given (css selector or xpath, basing on the first argument you’ve provided; css selector in my example above).

    Important note

    So, always try passing as much specific selector as it is possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this code to submit a form using cucumber When I fill in
I am trying to auto fill and submit the form using cURL, the code
I'm trying to fill out and submit a form using Python, but I'm not
I need to create c# code to go to site, fill in form submit
I have a form in my application that will fill using Unicode characters (Non
I need to know the information when i fill the form and then submit
I have some code that does custom drawing. Basically it is form fill program
I am trying to fill in a form using Javascript/ajax/php but the problem is
I am trying to auto fill a form (currently using contact form 7) with
I am using iText to fill pdf form, no error in console, but when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.