Anybody have idea how to test file download using cucumber?
相关问题
- I receive the error: cannot find module 'cucum
- Port of the Rails app when running Cucumber tests
- Getting scenario and steps undefined in cucumber w
- How to output Cucumber background steps before eac
- How do I close() and quit() Selenium driver withou
相关文章
- How do you run cucumber with Scala 2.11 and sbt 0.
- How to pass multiple parameter to Cucumber Runner
- Cucumber not serializing date string from datatabl
- selenium grid with cucumber
- How to get scenario name from a scenario outline i
- Handling excel spreadsheets with Cucumber Scenario
- Can you define instance variables during Cucumber&
- Guardfile for running single cucumber feature in s
I run selenium through chrome, when I'm testing that the csv has downloaded, I use the following in Ruby:
It simply looks in the default download directory and confirms that the file is there and outputs the filename within cmd.
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!
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
Inside your feature you can now do:
Cheers
For Chrome you can set the capability providing chrome options. Refer below code
then you can use exists() method of java.io.File to make sure if file exists.
On chrome I do it by opening the page:
chrome://downloads
and then use the shadow dom to retrieve the downloaded files:The downloaded files list also contain information such as file path and download date.