The JavaScript End to End Testing Framework is a highly popular framework nowadays. However, there are a few browser events that are not supported by cypress. File uploading is one such event.
To upload a file in cypress, you need to install a dependency to upload the file. Follow these steps:
- Install the dependency
npm install cypress-file-upload
- Add import
‘cypress-file-upload’; to cypress/support/commands.js file
-
Go to spec file where you are creating your test code:
declare a constant having path of your file and use attachFile command.
Example:
const urFilePath = 'abc.png';
cy.get('#elementID').attachFile(urFilePath);
Post a Comment