cucumber test file download

后端 未结 5 1264
渐次进展
渐次进展 2020-12-10 02:32

Anybody have idea how to test file download using cucumber?

5条回答
  •  悲哀的现实
    2020-12-10 02:51

    I found this to be a convenient way of testing for downloads, its a naiv way just testing for the headers put for most of the time its reasonable.

    If you are using capbybara then put the following inside your step_definitions.rb

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

    Inside your feature you can now do:

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

    Cheers

提交回复
热议问题