Monday, 15 September 2014

ruby on rails - cucumber file download with @javascript tag feature -



ruby on rails - cucumber file download with @javascript tag feature -

i using cucumber test application(which in rails). now, having problem test downloading file. using backbone putting @javascript tag @ every feature. have gone through solutions given in stackoverflow : cucumber test file download in rack-test. want know how click on file download box when have @javascript in cucumber? trying verify response headers : page.response_headers['content-type'].should == "text/csv" shows not supported in capybara.

any suggestion appreciated.

i assume utilize selenium driver default driver in case of @javascript.

selenium doesn't provide cross-browser solution this. want test application, not browser's native download windows should tell browser autosave downloaded files.

if you utilize firefox:

capybara.register_driver :selenium |app| profile = selenium::webdriver::firefox::profile.new profile['browser.download.dir'] = "/path-to-folder/webdriver-downloads" profile['browser.helperapps.neverask.savetodisk'] = "application/pdf" # content-type of file downloaded capybara::selenium::driver.new(app, :browser => :firefox, profile: profile) end

if you utilize google chrome:

capybara.register_driver :selenium |app| profile = selenium::webdriver::chrome::profile.new profile['download.prompt_for_download'] = false profile['download.default_directory'] = "/path/to/dir" capybara::selenium::driver.new(app, :browser => :chrome, profile: profile) end

then click link (which invokes file download) , file saved specified directory.

ruby-on-rails testing cucumber capybara

No comments:

Post a Comment