cucumber test file download

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

Anybody have idea how to test file download using cucumber?

5条回答
  •  我在风中等你
    2020-12-10 03:00

    This worked for me based when using send_data like so send_data(data, :filename => "inventory_#{Date.today.to_s}.csv", :disposition => 'attachment')

    Probably not best way to write the step, but it worked!

    Then /^I should receive a file(?: "([^"]*)")?/ do |file|
      result = page.response_headers['Content-Type'].should == "application/octet-stream"
      if result
        result = page.response_headers['Content-Disposition'].should =~ /#{file}/
      end
      result
    end
    

提交回复
热议问题