Skip to content

mvvitorsilvati/cypress-downloadfile

 
 

Repository files navigation

cypress-downloadfile

npm version

This is a Cypress custom file download command.

This repository is not maintained by the Cypress developers.

Installation

Install the module.

npm install cypress-downloadfile

Add the following line to cypress/support/commands.js.

require('cypress-downloadfile/lib/downloadFileCommand')

Add the following lines to cypress/plugins/index.js.

const {downloadFile} = require('cypress-downloadfile/lib/addPlugin')
module.exports = (on, config) => {
  on('task', {downloadFile})
}

If autocompletion does not work out of the box you can add the following line above your testfile

/// <reference types="cypress-downloadfile"/>

Example of basic command

cy.downloadFile('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg','mydownloads','example.jpg')

In Version 1.1.5 you can now also pass in the User-Agent. If no User-Agent is passed it will give a default User-Agent called request.

cy.downloadFile('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg','mydownloads','example.jpg','MyCustomAgentName')

Version 1.2.0

Because request is deprecated we changed to cross-fetch. This works on Cypress 3.8.0 and upwards. If you notice problems please let me know

About

Cypress File download custom command

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%