Test a download's filename with Cucumber

Posted Over 13 years ago. Visible to the public. Deprecated.

Selenium Driver no longer supports access to the response headers.

For alternative methods, see Testing File Downloads with Selenium

These steps are now part of Spreewald.

The step definitions below allow you to test the filename suggested by the server:

When I follow "Export as ZIP"
Then I should get a download with the filename "contacts_20110203.zip"

Capybara

Then /^I should get a download with the filename "([^\"]*)"$/ do |filename|
  page.driver.response.headers['Content-Disposition'].should include("filename=\"#{filename}\"")
end

Webrat

Then /^I should get a download with the filename "([^\"]*)"$/ do |filename|
  response.headers['Content-Disposition'].should include("filename=\"#{filename}\"")
end
Henning Koch
Last edit
Almost 7 years ago
Michael Leimstädtner
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-12-30 14:00)