Read more

Test a download's filename with Cucumber

Henning Koch
December 30, 2010Software engineer at makandra GmbH

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.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

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
Posted by Henning Koch to makandra dev (2010-12-30 15:00)