1

I have a test case which download the file in system default "Download" folder and at dynamic time I need to read this file from folder by applying filter on latest file.

Is there any way to read multiple files or files name from a folder in Cypress or in JavaScript ?

Vikas Bhargav
  • 73
  • 1
  • 3
  • 7
  • You might want to create a Cypress task. This way, you can use NodeJS File System module. Then you can call this task from your Cypress tests. – Yoann Picquenot Jun 15 '20 at 12:17

1 Answers1

1

Yes we can do that in cypress.

let fs = require("fs");
const fileList = fs.readFileSync('path/to/downloads/folder');

This will list the files name in an array. Now you can loop through it and use it. I got this solution from here.

In cypress we have to work with plugins and the detailed description is here

Prakash Dahal
  • 430
  • 3
  • 6