Cypress: Upload file

This is for future me as I will forget in the future. But feel free to go into detail if you want to learn uploading file in Cypress.

Github link of a test script: https://github.com/untoldstory69/cypressUploadFile

To upload a file in Cypress we need to install cypress-file-upload (https://www.npmjs.com/package/cypress-file-upload). We will use https://the-internet.herokuapp.com/upload for our testing purpose. Enter the following command in the terminal:

npm install –save-dev cypress-file-upload

The package name will appear in the package.json file.

Import cypress-file-upload in command.js file under the support folder.

import ‘cypress-file-upload’;

Write a test script to upload a file as shown in the attachment.

Finally, assert the file name after it is uploaded.

Published by Kishor Sharma

✔ QA Engineer since Jan 2014 ✔ Passionate to deliver the quality product. ✔ Requirement Analysis/ Requirement Engineering ✔ Manual Testing (Regression Engineer) ✔ Test Automation (Selenium Webdriver, Cucumber, Robot Framework, Protractor) ✔ Performance Testing (JMeter, Blazemeter, Taurus) ✔ Agile software development ✔ Scrum/JIRA/Kanban ✔ Jmeter (API Testing)

Leave your feedback...