From 59b625a5f90e615acb7e11b66d5d4b7aac0d464c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 16 May 2020 14:23:10 +0200 Subject: [PATCH 1/2] Simplify chromedriver installation with webdrivers This gem will automatically install chromedriver based on the installed version of Chrome/Chromium. --- .travis.yml | 6 ------ Dockerfile | 8 +------- Gemfile | 1 + Gemfile.lock | 5 +++++ README.md | 2 -- README_ES.md | 2 -- 6 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6741da68..5e9a2c028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,6 @@ addons: cache: bundler bundler_args: --without development before_script: -- wget -N https://chromedriver.storage.googleapis.com/2.36/chromedriver_linux64.zip -P ~/ -- unzip ~/chromedriver_linux64.zip -d ~/ -- rm ~/chromedriver_linux64.zip -- sudo mv -f ~/chromedriver /usr/local/share/ -- sudo chmod +x /usr/local/share/chromedriver -- sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver - for i in config/*.example; do cp "$i" "${i/.example}"; done - bundle exec rake db:setup script: diff --git a/Dockerfile b/Dockerfile index 10331fd7a..40744ae2e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,14 +41,8 @@ RUN gem install bundler # Finish establishing our Ruby environment RUN bundle install --full-index -# Install Chromium and ChromeDriver for E2E integration tests +# Install Chromium for E2E integration tests RUN apt-get update -qq && apt-get install -y chromium -RUN wget -N http://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip -RUN unzip chromedriver_linux64.zip -RUN chmod +x chromedriver -RUN mv -f chromedriver /usr/local/share/chromedriver -RUN ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver -RUN ln -s /usr/local/share/chromedriver /usr/bin/chromedriver # Copy the Rails application into place COPY . . diff --git a/Gemfile b/Gemfile index f3661c06c..19bf6b51e 100644 --- a/Gemfile +++ b/Gemfile @@ -85,6 +85,7 @@ group :test do gem "email_spec", "~> 2.2.0" gem "rspec-rails", "~> 3.8" gem "selenium-webdriver", "~> 3.141" + gem "webdrivers", "~> 4.3.0" end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 4494283b4..074151c9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -588,6 +588,10 @@ GEM activemodel (>= 4.2) debug_inspector railties (>= 4.2) + webdrivers (4.3.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (>= 3.0, < 4.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.4) @@ -691,6 +695,7 @@ DEPENDENCIES turnout (~> 2.4.0) uglifier (~> 4.1.2) web-console (~> 3.3.0) + webdrivers (~> 4.3.0) whenever (~> 0.10.0) wicked_pdf (~> 1.1.0) wkhtmltopdf-binary (~> 0.12.4) diff --git a/README.md b/README.md index c97f9c8c8..e2c87c9f6 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,6 @@ Run the app locally: bin/rails s ``` -Prerequisites for testing: install ChromeDriver >= 2.33 - Run the tests with: ```bash diff --git a/README_ES.md b/README_ES.md index d0426a980..107ee3e95 100644 --- a/README_ES.md +++ b/README_ES.md @@ -56,8 +56,6 @@ Para ejecutar la aplicación en local: bin/rails s ``` -Prerequisitos para los tests: tener instalado ChromeDriver >= 2.33 - Para ejecutar los tests: ``` From 2c4acb0bf78cd286c4e876970961a8fdc829290e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 16 May 2020 14:32:48 +0200 Subject: [PATCH 2/2] Use chromedriver 2.38 The latest stable version is causing problems on some machines, hanging forever in tests involving frames. So we're installing an old version which works with the latest Chrome. Note this means we're using an unsupported version. Officially, only the latest chromedriver supports the latest Chrome. We're using 2.38 instead of a more recent one (like 2.40) because it's the one we specified in our Dockerfile. See also: https://bugs.chromium.org/p/chromedriver/issues/detail?id=3361 --- spec/rails_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 3de8fd85d..28abc03d9 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -53,5 +53,6 @@ Capybara.register_driver :headless_chrome do |app| end Capybara.exact = true +Webdrivers::Chromedriver.required_version = "2.38" OmniAuth.config.test_mode = true