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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:42:51+00:00 2026-06-01T02:42:51+00:00

I am using Cucumber with Capybara to build my testing framework for a site.

  • 0

I am using Cucumber with Capybara to build my testing framework for a site. I have found a way using hooks to switch between the Capybara driver in Cucumber. I want to be able just to use RackTest when I am not testing for JavaScript because I was lead to believe RackTest is faster since it doesn’t render the page. Right now I have create 3 identical test that jump to Google and check that the title says Google. Each test uses a different driver. The Selenium and WebKit test work fine but the RackTest fails on the “I should see the title “Google”” test. I have attached a copy of my feature and steps and testing gems to this post.

Feature:

Feature: Rack Test
  In order to run test faster
  As a tester
  I want to use Rack Test to preform all non-javascript related test

  Scenario: Visit a page and check title
    When  I go to "http://www.google.com"
    Then  I should see the title "Google"

  @firefox
  Scenario: Visit a page and check title in Firefox
    When  I go to "http://www.google.com"
    Then  I should see the title "Google"

  @webkit
  Scenario: Visit a page and check title in WebKit
    When  I go to "http://www.google.com"
    Then  I should see the title "Google"

Steps:

When /^I go to "(http:\/\/[^"]*)"$/ do |url|
  visit url
end


Then /^I should see the title "([^"]*)"$/ do |title_cont|
  page.should have_selector "title", text: title_cont
end

Hooks:

Before('@firefox') do
  Capybara.current_driver = :selenium
end

Before('@webkit') do
  Capybara.current_driver = :webkit
end

After('@firefox, @webkit') do
  Capybara.use_default_driver
end

Gemfile:

group :test do
  gem 'capybara'
  gem 'capybara-webkit'
  gem 'cucumber'
  gem 'cucumber-rails'
  gem 'database_cleaner'
  gem 'factory_girl_rails'
  gem "rack-test", require: "rack/test"
  gem 'rspec'
  gem 'selenium-webdriver'
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-06-01T02:42:52+00:00Added an answer on June 1, 2026 at 2:42 am

    That’s because rack-test can only test Rack applications (e.g. your Ruby On Rails website). It’s not browser-based solution, while both Selenium and WebKit are. That’s why rack-test can’t access external websites (Google in your case).

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

Sidebar

Related Questions

I've been using Cucumber & Capybara for integration testing. Since the site uses a
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1, capybara-1.1.2 and factory_girl-2.6.3. I have
I'm using Cucumber and Capybara and I'd like a way to simulate the request
If I'm using cucumber/capybara with a selenium web driver to test, do I need
When using Cucumber with Capybara, I have to load test database data from SQL
I'm using rspec, cucumber and capybara and I'm looking for a way to test
I have a cucumber test (using Capybara) that needs to follow a link in
Given I have a rails app And I'm using cucumber And I'm using capybara
I am testing an API call to the server using Cucumber + Capybara with
I am using capybara along with cucumber on a Rails 2.3.9 project. I have

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.