Skip to content

Commit

Permalink
Cukes via Docker - selenium (Chrome in a container)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Sutton committed Dec 18, 2020
1 parent 99e6067 commit 21e9af2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ services:
- .:/app
ports:
- "3000:3000"
- "4000:4000"
- "35729:35729"
environment:
- HOSTNAME=localhost:3000
- DOCKERIZED=true
depends_on:
- postgresql

selenium_chrome:
image: selenium/standalone-chrome-debug
logging:
driver: none
ports:
- 5900:5900
23 changes: 22 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,33 @@
)
end

Capybara.register_driver :selenium_chrome_in_container do |app|
Capybara::Selenium::Driver.new app, browser: :remote, url: "http://selenium_chrome:444/wd/hub", desired_capabilities: :chrome
end

Capybara.register_driver :headless_selenium_chrome_in_container do |app|
Capybara::Selenium::Driver.new(
app,
browser: :remote,
url: "http://selenium_chrome:4444/wd/hub",
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w(headless disable-gpu) } )
)
end

Capybara.javascript_driver = if ENV['CAPYBARA_JAVASCRIPT_DRIVER']
ENV['CAPYBARA_JAVASCRIPT_DRIVER'].to_sym
else
:selenium
:headless_selenium_chrome_in_container
end

Capybara.server_host = '0.0.0.0'

Capybara.server_port = 4000

Capybara.app_host = 'http://app:4000'

Capybara.always_include_port = true

if ENV['BROWSER']
DatabaseCleaner.strategy = :truncation
Capybara.default_driver = ENV['BROWSER'].to_sym
Expand Down

0 comments on commit 21e9af2

Please sign in to comment.