I'm trying to follow the tutorial set out in The RSpec Book and I'm onto the chapter about making Webrat work with Selenium.
Here is my features/support/env.rb (following the directions detailed within the book):
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
require 'cucumber/rails/active_record'
require 'cucumber/web/tableish'
require 'webrat'
require 'webrat/core/matchers'
Webrat.configure do |config|
config.mode = :selenium #was :rack
config.application_framework = :rack
config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end
ActionController::Base.allow_rescue = false
Cucumber::Rails::World.use_transactional_fixtures = false
if de开发者_JAVA技巧fined?(ActiveRecord::Base)
begin
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
rescue LoadError => ignore_if_database_cleaner_not_present
end
end
class ActiveSupport::TestCase
setup do |session|
session.host! "localhost:3001"
end
end
When I run rake cucumber I get the following error:
Failed to start new browser session: Error while launching browser (Selenium::CommandError)
I tried replacing selenium-server.jar in the webrat gem folder with the 1.0.3 version, according to a fix detailed in a number of places on the web, but I still get this same error message.
While the cucumber task is executing, firefox does flash on the screen. I've tried both with and without firefox already open - same error. I'm on a Debian machine and using webrat 0.7.3 and selenium-client (1.2.18) according to gem list.
I have no idea how to approach this one. :/
The way I have approached this problem after having the same nasty error is by:
- gem install webrat
- gem install selenium-client
- gem install selenium
- selenium install - this will grab the latest selenium server packaged as a jar
- selenium - this will start the server
- cucumber in your rails root directory to see all greens provided that you have done the appropriate setup mentioned above in the question.
It may well be a quick and dirty solution but it works with latest versions of all gems and allows to run tests. I would welcome more appropriate setup but for now this will do for me.
精彩评论