【问题标题】:Webrat Selenium: Failed to start new browser session: Error while launching browser (Selenium::CommandError)Webrat Selenium:无法启动新的浏览器会话:启动浏览器时出错 (Selenium::CommandError)
【发布时间】:2011-05-06 13:18:16
【问题描述】:

我正在尝试按照 The RSpec Book 中的教程进行操作,并且正在阅读有关使 Webrat 与 Selenium 一起工作的章节。

这是我的 features/support/env.rb(按照书中详细说明):

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 defined?(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

当我运行 rake cucumber 时出现以下错误:

Failed to start new browser session: Error while launching browser (Selenium::CommandError)

我尝试将 webrat gem 文件夹中的 selenium-server.jar 替换为 1.0.3 版本,根据网络上许多地方详细说明的修复,但我仍然收到同样的错误消息。

在执行黄瓜任务时,firefox 会在屏幕上闪烁。我已经尝试过打开和不打开firefox - 同样的错误。我在 Debian 机器上,根据 gem 列表使用 webrat 0.7.3 和 selenium-client (1.2.18)。

我不知道如何处理这个问题。 :/

【问题讨论】:

  • 这是一个很好的资源,可以帮助解决我遇到的同样问题的其他人:qaautomation.net/?p=15(尽管它不是我的解决方案。)

标签: ruby-on-rails firefox selenium webrat


【解决方案1】:

在遇到同样令人讨厌的错误后,我解决此问题的方法是:

  1. gem 安装 webrat
  2. gem 安装 selenium-client
  3. gem 安装硒
  4. selenium 安装 - 这将获取打包为 jar 的最新 selenium 服务器
  5. selenium - 这将启动服务器
  6. 如果您已完成上述问题中提到的适当设置,请在您的 rails 根目录中查看所有果岭。

这可能是一个快速而肮脏的解决方案,但它适用于所有 gem 的最新版本并允许运行测试。我会欢迎更合适的设置,但现在这对我来说是可行的。

【讨论】:

    猜你喜欢
    • 2010-11-27
    • 2023-03-10
    • 2011-03-24
    • 2015-04-08
    • 2012-04-21
    • 2011-01-07
    • 2020-04-23
    • 2023-03-22
    • 1970-01-01
    相关资源
    最近更新 更多