Cypress Tutorial For Beginners : Part 2 ( Upload a File )

Cypress Tutorial For Beginners Upload a files

In this video cypress tutorial for beginners, We are going to learn how to upload a file in cypress and create our first script to test to upload a file and check that file is uploaded successfully. 

Contents

Cypress Upload File

You need to install

  1. Download the node module  :  npm i cypress-file-upload

2. Require it in your script

import 'cypress-file-upload';

3. Now use the Fixture method to upload the file.

const fileName = 'data.json';
cy.fixture(fileName).then(fileContent => {
cy.get('[data-cy="file-input"]').upload({ fileContent, fileName, mimeType: 'application/json' });
});

-----------------------------------------------------
πŸ‘ͺ Join our Community - http://bit.ly/learntesting2019
βœ… Automation Community - https://thetestingacademy.com
🐦Follow us on Twitter - https://twitter.com/itstechmode
πŸ“– Like us on Facebook - https://www.facebook.com/scrolltest
🎀 Listen to our Podcast - https://anchor.fm/thetestingacademy
------------------------------------------------------

#automationtesting #manualtesting #testautomation #thetestingacademy #scrolltest

Similar Posts