This was tested on a Mac running 10.13.6 High Sierra.
Why? I wanted to be able to stop a system spec mid-run if I was having issues with it.
On the mac host:
Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install xQuartz (an X server for mac)
brew cask install xquartz
Run xquartz. In Preferences > Security > Allow Connections from network clients <- Make sure this is checked.
Log out, log in your mac.
Open xquartz terminal:
xhost +127.0.0.1
Share the host's X dir and DISPLAY var with the container. In docker-compose.yml, add this volume:
containername:
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
...
environment:
DISPLAY: host.docker.internal:0
Add this somewhere before your tests run:
require 'selenium/webdriver'
Capybara.register_driver(:selenium_chrome) do |app|
options = Selenium::WebDriver::Chrome::Options.new(
args: %w[
no-sandbox
disable-setuid-sandbox
disable-extensions
window-size=1366,768
use-gl=swiftshader
]
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
service: Selenium::WebDriver::Service.new(path: '/usr/local/bin/chromedriver', port: 3333), # I had to specify the chromedriver location. YMMV
options: options
)
end
Capybara.javascript_driver = :selenium_chrome