shipstar / rspec-with-multiple-webdrivers

Reproduction of a setup that causes RSpec specs to hang with multiple webdrivers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overview

This repository reproduces a minimal set of conditions that caused the Rails test runner to hang if there are multiple webdrivers configured, but using RSpec instead. A high-level overview of the setup:

  • cuprite + selenium
  • RSpec system + feature specs
  • Postgres

I added the following config block to spec/rails_helper.rb:

config.before(type: :system) do
  driven_by :cuprite, using: :chromium, screen_size: [1400, 1400]
end

config.before(type: :system, driver: :selenium) do
  driven_by :selenium_headless, using: :chromium, screen_size: [1400, 1400]
end

Capybara.register_driver(:cuprite) do |app|
  Capybara::Cuprite::Driver.new(app, browser: :chrome)
end

Capybara.register_driver(:selenium_headless) do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome("goog:loggingPrefs" => {browser: "ALL"})
  browser_options = Selenium::WebDriver::Chrome::Options.new(args: ["--headless"])

  Capybara::Selenium::Driver.new(app, browser: :chrome, capabilities: [capabilities, browser_options])
end

config.before(type: :feature) do
  Capybara.current_driver = :cuprite
end

config.before(type: :feature, driver: :selenium_headless) do
  Capybara.current_driver = :selenium_headless
end

config.after(type: :feature) do
  Capybara.use_default_driver
end

I made a HomeController with a simple 2-sentence show view. I then wrote two RSpec system/feature specs that visit that home page - one using Cuprite (the default) and one using Selenium (tagged with driver: :selenium_headless per above).

The tests run and pass, but still hang at the end despite switching the test runner:

The companion repository using the Rails test runner is here.

About

Reproduction of a setup that causes RSpec specs to hang with multiple webdrivers


Languages

Language:Ruby 81.1%Language:HTML 14.0%Language:JavaScript 3.1%Language:CSS 1.8%