Excel file upload/import using cypress

Viewed 1560

I've a UI similar to enter image description here

I need to upload a xlsx file which I have placed in fixture folder in to the application. Any suggestions how to do it using cypress?

1 Answers

This what I found as the solution

  1. Install cypress-file-upload

    npm install --save-dev cypress-file-upload

  2. Add following to command .js file

    import 'cypress-file-upload';

  3. Use cy.attachFile

const yourFixturePath = 'data.json'; cy.get('[data-cy="file-input"]').attachFile(yourFixturePath);

For details https://www.npmjs.com/package/cypress-file-upload

Related