Cypress Download File
npm install --save-dev cypress-downloadfile
Note: In case you get error
Try below command
npm install -g npm-audit-resolver
resolve-audit
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})
}
Sample Code for Download File
context('Window', () => {
beforeEach(() => {
cy.visit('https://the-internet.herokuapp.com/upload')
})
it('Download', () => {
cy.downloadFile('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf','Download','demo.pdf')
})
})
No comments:
Post a Comment