Goodbye phantomjs, hello (again) selenium.

This commit is contained in:
James Mason 2018-10-25 10:50:13 -07:00
parent 078031e679
commit 9eae73c7e4
4 changed files with 56 additions and 22 deletions

View file

@ -252,10 +252,11 @@ end
group :test do
# as test framework
gem 'capybara'
gem 'chromedriver-helper'
gem 'database_cleaner'
gem 'phantomjs', :require => 'phantomjs/poltergeist'
gem 'poltergeist'
gem 'geckodriver-helper'
gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
gem 'selenium-webdriver'
# for measuring test coverage
gem 'codecov', require: false
# for describing models

View file

@ -64,6 +64,8 @@ GEM
airbrake-ruby (2.12.0)
ajax-datatables-rails (0.4.3)
railties (>= 4.0)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (7.1.4)
ast (2.4.0)
autoprefixer-rails (9.3.1)
@ -104,10 +106,14 @@ GEM
chart-js-rails (0.1.6)
railties (> 3.1)
chartkick (3.0.1)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (2.1.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
chronic (0.10.2)
chunky_png (1.3.8)
climate_control (0.2.0)
cliver (0.3.2)
cloudinary (1.9.1)
aws_cf_signer
rest-client
@ -179,6 +185,8 @@ GEM
actionpack (>= 3.2.13)
formtastic-bootstrap (3.1.1)
formtastic (>= 3.0)
geckodriver-helper (0.21.0)
archive-zip (~> 0.7)
globalid (0.4.1)
activesupport (>= 4.2.0)
gravtastic (3.2.6)
@ -225,6 +233,7 @@ GEM
i18n_data (0.8.0)
inversion (1.1.1)
loggability (~> 0.12)
io-like (0.3.0)
iso-639 (0.2.8)
jaro_winkler (1.5.1)
jquery-datatables-rails (3.4.0)
@ -334,16 +343,10 @@ GEM
ast (~> 2.4.0)
pdf-core (0.2.5)
pg (1.1.2)
phantomjs (2.1.1.0)
piwik_analytics (1.0.2)
actionpack
activesupport
rails (>= 3.0.0)
poltergeist (1.9.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
powerpack (0.1.2)
prawn (1.0.0)
pdf-core (~> 0.2.2)
@ -502,6 +505,9 @@ GEM
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selectize-rails (0.12.6)
selenium-webdriver (3.14.1)
childprocess (~> 0.5)
rubyzip (~> 1.2, >= 1.2.2)
sexp_processor (4.11.0)
shellany (0.0.1)
shoulda-matchers (2.8.0)
@ -602,6 +608,7 @@ DEPENDENCIES
carrierwave-bombshelter
chart-js-rails
chartkick
chromedriver-helper
climate_control
cloudinary
cocoon
@ -621,6 +628,7 @@ DEPENDENCIES
font-awesome-rails
formtastic (~> 3.1.5)
formtastic-bootstrap
geckodriver-helper
gravtastic
guard-rspec
haml-rails
@ -645,9 +653,7 @@ DEPENDENCIES
omniauth-openid
paper_trail
pg
phantomjs
piwik_analytics (~> 1.0.1)
poltergeist
prawn-qrcode (~> 0.2.2.1)
prawn_rails
puma (~> 3.0)
@ -680,6 +686,7 @@ DEPENDENCIES
ruby-oembed (~> 0.12.0)
sass-rails (>= 4.0.2)
selectize-rails
selenium-webdriver
shoulda-matchers
skylight
spring-commands-rspec

View file

@ -115,3 +115,12 @@
# Speeds up turn around times of tests
# OSEM_FACTORY_LINT=false
# How should browser tests be performed?
# For headless Chrome (default):
# OSEM_TEST_DRIVER=chrome_headless
# For Chrome:
# OSEM_TEST_DRIVER=chrome
# For headless Firefox:
# OSEM_TEST_DRIVER=firefox_headless
# For Firefox:
# OSEM_TEST_DRIVER=firefox

View file

@ -18,9 +18,7 @@ require 'shoulda/matchers'
# all migrations applied
ActiveRecord::Migration.maintain_test_schema!
# Add poltergeist to use it as JS driver
require 'capybara/poltergeist'
require 'phantomjs'
require 'selenium/webdriver'
# Adds rspec helper provided by paper_trail
# makes it easier to control when PaperTrail is enabled during testing.
@ -59,18 +57,37 @@ RSpec.configure do |config|
# --seed 1234
config.order = 'random'
# poltergeist as a underlying mech for Capybara
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :firefox do |app|
Capybara::Selenium::Driver.new(app, browser: :firefox)
end
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(
app,
phantomjs: Phantomjs.path,
js_errors: false,
window_size: [1920, 1080]
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :firefox_headless do |app|
options = Selenium::WebDriver::Firefox::Options.new
options.args << '--headless'
options.args << '--window-size=1920,1080'
Capybara::Selenium::Driver.new(app, browser: :firefox, options: options)
end
Capybara.register_driver :chrome_headless do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu) }
)
Capybara::Selenium::Driver.new(
app, browser: :chrome, desired_capabilities: capabilities
)
end
Capybara.default_max_wait_time = 10 # seconds
# use a real browser for JS tests
Capybara.javascript_driver = (
ENV['OSEM_TEST_DRIVER'].try(:to_sym) || :chrome_headless
)
# Includes helpers and connect them to specific types of tests
config.include FactoryBot::Syntax::Methods
config.include OmniauthMacros