I'm writing tests that downloads a PDF and opens it in browser so that I can confirm some content within. I'm struggling to find a solution to configure Chromedriver to download and open instead of saving to the downloads folder (default).
Is there a way I can do this?
Thanks
Currently (2015-07-12) this is an open issue in chromedriver.
See: https://code.google.com/p/chromedriver/issues/detail?id=1081 for details.
You may be able to work-around it by configuring the chrome profile. Based on the information in the bug you might try something like:
Capybara.register_driver :chrome_pdf do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
"chromeOptions" => {
"excludeSwitches" => [ "test-type", "ignore-certificate-errors" ],
}
)
Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => caps)
end
And set:
Capybara.javascript_driver = :chrome_pdf
or just switch to this driver when needed:
Capybara.current_driver = :chrome_pdf