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

  • SEARCH
  • Home
  • 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 6192377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:55:59+00:00 2026-05-24T02:55:59+00:00

I have a step definition in my cucumber test suite that authenticates the user

  • 0

I have a step definition in my cucumber test suite that authenticates the user and to try and speed up my test suite, I want this step to check the user is already authenticated. Perhaps this is a bad idea because it means tests may depend on each other… I don’t know. But how would I do this? I am not fluent in Ruby, unfortunately.

I am hoping that I can render a class in the DOM so I can test against this with have_selector or something. This might also be a bad idea too…

Given /^I am authenticated as a "([^"]*)" user$/ do |role|
  #TODO: only do this if the user is not authenticated
  visit('/login')
  fill_in "name", :with => "something"
  fill_in "pass", :with => "password"
  click_button
  response_body.should contain("Log out")
end
  • 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-24T02:56:00+00:00Added an answer on May 24, 2026 at 2:56 am

    You’re right this would be a bad idea. But if you really want to do it the correct way would be checking any kind of text on the page, for example you can have status bar with logged in username. This would be correct way because it simulates the behavior of a human, something like – oh, here is my username – it means that I’m already logged in:)

    Here is how your step could look like:

     Given /^I am authenticated as a "([^"]*)" user$/ do |role|
       unless page.has_content?(username)
         visit('/login')
         fill_in "name", :with => "something"
         fill_in "pass", :with => "password"
         click_button
         response_body.should contain("Log out")
       end
     end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a step definition cucumber like this find(div#cycle_form table).should have_content(append_row_to_table_tag(day_num, hour, hour_night)) Method
I'm getting started with cucumber, and I have written the following step definition, which
I have configured cuke4duke and Cucumber with maven and written feature and step definition
I'm using following construct in a cucumber step definition. Given I have following stuff
I have a step in my application where a user repeatedly hears three spoken
I have many jobs that have a step to send 1 specific email out
I have a three-step process that is entirely reliant upon JavaScript and Ajax to
I have a post-compilation step that manipulates the Java bytecode of generated classes. I'd
I have a custom script step in my build process that zips the executable.
I have the problem that an specific step in Ant can only be executed

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.