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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:31:20+00:00 2026-06-10T13:31:20+00:00

I have a feature in my Ruby on Rails application that works just fine

  • 0

I have a feature in my Ruby on Rails application that works just fine with the message “Responds to browser_basic_authorize” from the background given step.

However, if I add a @javascript tag before the scenario, then my background given fails with “I don’t know how to login”.

What’s going wrong, and how do I go about testing JavaScript interactions on my application?

Background:
    Given I perform HTTP authentication as "<id>/<password>"
    When I go to the homepage
    Then I should see "Text-that-you-should-see-on-your-home-page"

Scenario: Displaying injury causative factors
    Given I am on the new_incident_report page
    When I choose "incident_report_employee_following_procedures_true"
    Then I should see "Equipment failure?"
    Then I should not see "Lack of training"

When /^I perform HTTP authentication as "([^\"]*)\/([^\"]*)"$/ do |username, password|
    puts "id/pswd: #{username}/#{password}"
    ### Following works ONLY if performed first before even going to a page!!!
    if page.driver.respond_to?(:basic_auth)
        puts 'Responds to basic_auth'
        page.driver.basic_auth(username, password)
    elsif page.driver.respond_to?(:basic_authorize)
        puts 'Responds to basic_authorize'
        page.driver.basic_authorize(username, password)
    elsif page.driver.respond_to?(:browser) && page.driver.browser.respond_to?(:basic_authorize)
        puts 'Responds to browser_basic_authorize'
        page.driver.browser.basic_authorize(username, password)
    else
        raise "I don't know how to log in!"
    end
end

I am using Ruby on Rails 3.0.9, current gems, and other tests are passing.

  • 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-10T13:31:22+00:00Added an answer on June 10, 2026 at 1:31 pm

    I presume that your @javascript driver is Selenium as that is the default. The advice given in the Selenium Core FAQ regarding basic authentication is to supply the username and password in the URL e.g. http://user:pass@myexample.com/blah.

    I haven’t been able to find a definitive answer, but it appears that Selenium Webdriver (as used by Capybara), doesn’t support accessing or modifying HTTP headers, so supplying this information in the URL is probably the only way.

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

Sidebar

Related Questions

I have built a blog application w/ ruby on rails and I am trying
I'm creating a simple paste-bin in Ruby on Rails, which will have an expire-feature.
I have just upgraded to ruby 1.9.3-p125 (from 1.9.3-p0). All tests were working before
1.My Ruby on Rails application doesn't have a database. 2.All functionalities even login is
This Ruby on Rails problem is a bit vexing, as the code works fine
I have a feature of my application which depends on alternate-click. Windows users don't
I have a feature that uses the camera so I can test it only
With the 2.3.x+ rails feature of nested models, I think I need to have
I have deployed a Rails application on Heroku (web-server thin). When I push it,
Very soon I plan on deploying my first Ruby on Rails application to a

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.