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 6776537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:02:29+00:00 2026-05-26T16:02:29+00:00

When writing my scenerios, is it possible to not have to hard code text

  • 0

When writing my scenerios, is it possible to not have to hard code text in the steps?

Like say I am insert a username in a textbox field, and a password in the password field.

If I need to do this in many places, it would be a pain to fix.

Example:

Given I am the registered member "myusername"
And I am on the login page
When I fill in "email" with "email@example.com"
And I fill in "password" with "123"
And I press "Login"
Then I should see "Account Activity"

I don’t want my username, email, and password hard-coded.

  • 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-05-26T16:02:30+00:00Added an answer on May 26, 2026 at 4:02 pm

    Okay, you’re still using the older version of the cucumber-rails gem which comes with the training wheels installed by default. Read this post by Aslak Hellesøy “The training wheels came off”.

    The gist of the post is that using web_steps.rb, although it having been the “standard” for years is now terribly wrong and that we should feel bad for doing that.

    The purpose of Cucumber is to use it to make readable / understandable features for all people.

    Writing a scenario like this is long and boring:

    And I am on the login page
    When I fill in "email" with "email@example.com"
    And I fill in "password" with "123"
    And I press "Login"
    Then I should see "Account Activity"
    

    What you want to actually be testing is that you should be able to login and after that see something to do with being logged in. Whatever that something is shouldn’t be written in the scenario.

    So ideally, your Scenario (in a more exciting fashion) would look like this:

    When I login successfully
    Then I should see that I am logged in
    

    Then the task of doing the legwork goes to some new step definitions. Those two steps aren’t defined automatically for you, like web_steps.rb does, but rather need to have them written in a file within feature/step_definitions. What you call the file is up to you, but it’ll contain content similar to this:

    When /I login successfully/ do
      visit root_path
      click_link "Login"
      fill_in "Email", :with => "you@example.com"
      fill_in "Password", :with => "password"
    end
    
    Then /^I should see I am logged in$/ do
      page.should have_content("Account Activity")
    end 
    

    No more excessive web_steps.rb file and cleaner step definitions. Exactly what Cucumber should be.

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

Sidebar

Related Questions

Possible Duplicate: Datatemplate inheritance I have several data types that are not subclasses, nor
Writing the code for the user authentication portion of a web site (including account
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing documentation in html requires some code examples. What to do with characters that
It's not possible to inherit from a C# struct. It's not obvious to me
I'm writing a program in C# that needs to insert data in multiple tables.
Is it possible to return an error code from a perl script? I am
I'm writing RESTful service with C#/wcf and need to put filters on GET. Like
I do not believe that it is possible to completely avoid C-style casts 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.