Webrat Selenium:无法启动新的浏览器会话:启动浏览器时出错(Selenium::CommandError)

发布于 2024-10-13 02:19:57 字数 1515 浏览 2 评论 0原文

我正在尝试遵循 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 版本,根据网络上许多地方详细说明的修复,但我仍然收到相同的错误消息。

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

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

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 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

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. :/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗地喜欢 2024-10-20 02:19:57

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

  1. gem install webrat
  2. gem install selenium-client
  3. gem install selenium
  4. selenium install - 这将获取打包为 jar 的最新 selenium 服务器
  5. selenium - 这将启动服务器
  6. cucumber如果您已完成问题中提到的上述适当设置​​,您的 Rails 根目录即可查看所有绿色内容。

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

The way I have approached this problem after having the same nasty error is by:

  1. gem install webrat
  2. gem install selenium-client
  3. gem install selenium
  4. selenium install - this will grab the latest selenium server packaged as a jar
  5. selenium - this will start the server
  6. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文