From 2ea320a245a48e3571ea34b942dbaed3ed341097 Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Thu, 30 Apr 2020 05:07:45 -0400 Subject: [PATCH] Support docker-selenium (#7583) * Support use of selenium-docker * Apply suggestion * Add documentation --- docs/installation/windows.md | 16 ++++++++++++++++ spec/support/initializers/capybara.rb | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/installation/windows.md b/docs/installation/windows.md index 3c0cf52e0..e19dbeea2 100644 --- a/docs/installation/windows.md +++ b/docs/installation/windows.md @@ -218,5 +218,21 @@ cd automake-1.10/ make ``` +### WSL2 and System test + +In WSL2, hostname/IP address are no longer shared between Windows and Linux. +There are currently two work-arounds. + +1. Use dockerized selenium, ie docker-selenium. You will need docker for the + following steps + + 1. `docker run -d --name selenium-hub -p 4444:4444 selenium/hub:3.141.59-20200409` + 2. `CH=$(docker run --rm --name=ch --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome:3.141.59-20200409)` + 3. Add `SELENIUM_URL: "http://localhost:4444/wd/hub"` to your + `application.yml` + 4. Run your System test! + +2. Port forward with `socats` (more info needed). + > If you encountered any errors that you subsequently resolved, **please > consider updating this section** with your errors and their solutions. diff --git a/spec/support/initializers/capybara.rb b/spec/support/initializers/capybara.rb index c6bf162af..d05f6deaf 100644 --- a/spec/support/initializers/capybara.rb +++ b/spec/support/initializers/capybara.rb @@ -21,7 +21,16 @@ RSpec.configure do |config| end config.before(:each, type: :system, js: true) do - driven_by :headless_chrome + if ENV["SELENIUM_URL"].present? + # Support use of remote chrome testing. + Capybara.server_host = ENV.fetch("CAPYBARA_SERVER_HOST") { "0.0.0.0" } + ip = Socket.ip_address_list.detect(&:ipv4_private?).ip_address + host! URI::HTTP.build(host: ip, port: Capybara.server_port).to_s + + driven_by :selenium, using: :chrome, screen_size: [1400, 2000], options: { url: ENV["SELENIUM_URL"] } + else + driven_by :headless_chrome + end end end