How to Download File with Cypress - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Thursday, 16 July 2020

How to Download File with Cypress

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