1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Use the Selenium Chrome driver download_path=

This commit is contained in:
Thomas Walpole 2018-06-25 23:08:41 -07:00
parent 4da9195870
commit 121c391492

View file

@ -13,13 +13,7 @@ CHROME_DRIVER = ENV['HEADLESS'] ? :selenium_chrome_headless : :selenium_chrome
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
@ -28,14 +22,7 @@ Capybara.register_driver :selenium_chrome_headless do |app|
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