A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jeroenvandijk/capybara-mechanize below:

phillbaker/capybara-mechanize: RackTest driver for Capybara with remote request support

This gem makes it possible to use Capybara for (partially) remote testing. It inherits most functionality from the RackTest driver and only uses Mechanize for remote requests.

It is currently in use to test the integration between a Rails application and Twitter authorization and sharing.

This gem is a Capybara extension. I have been inspired by the Capybara driver and some earlier efforts for a Mechanize driver.

Thanks to Pinkelstar for giving me the time and the need to develop this gem.

gem install capybara-mechanize

For support with:

require 'capybara/mechanize'
Further configuration of Mechanize

Upon instantiation of a Driver, you can configure mechanize agent options in a #configure block:

Capybara.register_driver :mechanize do |app|
  driver = Capybara::Mechanize::Driver.new(app)
  driver.configure do |agent|
    # Configure other Mechanize options here.
    agent.log = Logger.new "mech.log"
    agent.user_agent_alias = 'Mac Safari'
  end
  driver
end

You can configure it to use for external servers. Until this issue #66 is resolved, you can configure with

Capybara.register_driver :mechanize do |app|
  Capybara::Mechanize::Driver.new(proc {})
end

and use like this

session = Capybara::Session.new :mechanize
session.visit 'https://github.com'
Usage with Cucumber and tags

A @mechanize tag is added to your hooks when you add the following line to your env.rb

require 'capybara/mechanize/cucumber'

The following scenario will then be using the Mechanize driver

@mechanize
Scenario: do something remote
  When I click the remote link

When you want to use this driver to test a remote application. You have to set the app_host:

Capybara.app_host = "http://www.yourapp.com"

Note that I haven't tested this case for my self yet. The Capybara tests pass for this situation though so it should work! Please provide me with feedback if it doesn't.

If you receive the error Net::HTTP::Persistent::Error: too many connection resets, try setting a timeout value: page.driver.browser.agent.idle_timeout = 0.4.

Run bundler

Then you are ready to run the test like so

Note on Patches/Pull Requests

Copyright (c) 2010-2013 Jeroen van Dijk. See LICENSE for details.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4