Skip to content

Commit

Permalink
Use the Selenium Chrome driver download_path=
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jun 26, 2018
1 parent 4da9195 commit 121c391
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions spec/selenium_spec_chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@

Capybara.register_driver :selenium_chrome do |app|
driver = Capybara::Selenium::Driver.new(app, browser: :chrome)
# TODO: Fix this when selenium with `download_path =` support is released
bridge = driver.browser.send(:bridge)
params = { cmd: 'Page.setDownloadBehavior', params: { behavior: 'allow', downloadPath: Capybara.save_path } }
command = +'/session/:session_id/chromium/send_command'
command[':session_id'] = bridge.session_id
bridge.http.call(:post, command, params)

driver.browser.download_path = Capybara.save_path
driver
end

Expand All @@ -28,14 +22,7 @@
browser_options.args << '--headless'
browser_options.args << '--disable-gpu' if Gem.win_platform?
driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)

# TODO: Fix this when selenium with `download_path =` support is released
bridge = driver.browser.send(:bridge)
params = { cmd: 'Page.setDownloadBehavior', params: { behavior: 'allow', downloadPath: Capybara.save_path } }
command = +'/session/:session_id/chromium/send_command'
command[':session_id'] = bridge.session_id
bridge.http.call(:post, command, params)

driver.browser.download_path = Capybara.save_path
driver
end

Expand Down

0 comments on commit 121c391

Please sign in to comment.