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:
parent
4da9195870
commit
121c391492
1 changed files with 2 additions and 15 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue