Ruby on rails Capybara.javascript_driver=:poltergeist在测试期间不显示浏览器
我试图使用poltergeist进行测试,但在运行测试时,浏览器不会显示 这是我的Ruby on rails Capybara.javascript_driver=:poltergeist在测试期间不显示浏览器,ruby-on-rails,rspec,capybara,poltergeist,Ruby On Rails,Rspec,Capybara,Poltergeist,我试图使用poltergeist进行测试,但在运行测试时,浏览器不会显示 这是我的spec\u helper.rb: # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' req
spec\u helper.rb
:
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'rspec/page-regression'
require 'capybara/rspec'
require 'capybara/rails'
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
#Capybara::Poltergeist::Driver.new(app, {debug: true, :timeout => 90})
Capybara::Poltergeist::Driver.new(app, {debug: false, :default_wait_time => 30, :timeout => 90})
end
Capybara.javascript_driver = :poltergeist
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
# config.use_transactional_fixtures = false
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
config.include Capybara::DSL
end
# from http://stackoverflow.com/questions/8524839/sending-rails-errors-to-rspec-output
# to output all errors to rspec output
ActionController::Base.class_eval do
def rescue_action(exception)
raise exception
end
end
我不知道我是否正确设置了
Capybara.javascript\u驱动程序
您将看不到浏览器。Poltergeist用于无头测试,这意味着它以编程方式呈现下面的所有内容,并以编程方式处理与页面的交互。您将看不到浏览器。Poltergeist用于无头测试,这意味着它以编程方式呈现下面的所有内容,并以编程方式处理与页面的交互。如果要查看浏览器,为什么要使用Poltergeist?来自:“它允许您在无头WebKit浏览器上运行水豚测试”。表示“已配置为在没有监视器的情况下运行的设备”。听起来像是“按预期工作”。有时查看浏览器以便确认测试中的错误是有益的。是的,您可以通过控制台检查DOM,并重新组装所有东西——但这很乏味。浏览器显示通常在运行期间通过ENV标志完成。如果要查看浏览器,为什么要使用poltergeist?来自:“它允许您在无头WebKit浏览器上运行水豚测试”。表示“已配置为在没有监视器的情况下运行的设备”。听起来像是“按预期工作”。有时查看浏览器以便确认测试中的错误是有益的。是的,您可以通过控制台检查DOM,并重新组装所有东西——但这很乏味。浏览器显示通常在运行期间通过ENV标志完成