Skip to content

Commit

Permalink
tweak selenium container prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
librod89 committed Aug 14, 2021
1 parent dc6d267 commit ccbb4c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
uses: docker/setup-buildx-action@v1
- name: Build
run: docker-compose build
- name: bundle install
run: docker-compose run web bundle install
- name: db:reset
run: docker-compose run web rails db:reset
- name: docker UP
Expand Down
23 changes: 11 additions & 12 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@

# used in docker
Capybara.register_driver :selenium_chrome_headless_in_container do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.args << "--headless"
opts.args << "--disable-gpu"
opts.args << "--disable-site-isolation-trials"
opts.args << "--window-size=1280,900"
end
browser_options.add_preference(:download, prompt_for_download: false, default_directory: DownloadHelpers::PATH.to_s)

browser_options.add_preference(:browser, set_download_behavior: {behavior: "allow"})

Capybara::Selenium::Driver.new app,
browser: :remote,
url: "http://selenium_chrome:4444/wd/hub",
options: browser_options
capabilities: [Selenium::WebDriver::Remote::Capabilities.chrome(
"goog:chromeOptions" => {
"args" => %w[headless disable-gpu window-size=1280,900],
"prefs" => {
"download.prompt_for_download" => false,
"download.default_directory" => "/home/seluser/Downloads",
"browser.set_download_behavior" => { "behavior" => "allow" }
}
}
)]
end

# used without docker
Expand All @@ -52,7 +51,7 @@
config.include DownloadHelpers
clear_downloads
if ENV["DOCKER"]
driven_by :selenium_chrome_in_container
driven_by :selenium_chrome_headless_in_container
Capybara.server_host = "0.0.0.0"
Capybara.server_port = 4000
Capybara.app_host = "http://web:4000"
Expand Down

0 comments on commit ccbb4c0

Please sign in to comment.