cypress-example-recipes icon indicating copy to clipboard operation
cypress-example-recipes copied to clipboard

Use data from excel spreadsheet

Open jennifer-shehane opened this issue 7 years ago • 6 comments

Similar to how DataProvider works for Selenium.

jennifer-shehane avatar Apr 26 '18 18:04 jennifer-shehane

found a useful link :- https://rjzaworski.com/2013/01/parameterized-testing-in-javascript

However , grabbing data from excel is where I got stuck , coz while using modules such as 'xlsx' to convert excel data to json to pass it into parameters , cypress throws an error _fs.readfileSync is not a function.

Since xlsx.readFile function is 'Node Only' Function and might be the code is being executed in the browser domain .

I am quite new to cypress , but having this functionality will be significantly better.

yogitthakral avatar Mar 03 '19 13:03 yogitthakral

Try using cy.task to read and convert that file - task runs in Node context

Sent from my iPhone

On Mar 3, 2019, at 08:17, Yogit Thakral [email protected] wrote:

found a useful link :- https://rjzaworski.com/2013/01/parameterized-testing-in-javascript

However , grabbing data from excel is where I got stuck , coz while using modules such as 'xlsx' to convert excel data to json to pass it into parameters , cypress throws an error _fs.readfileSync is not a function.

Since xlsx.readFile function is 'Node Only' Function and might be the code is being executed in the browser domain .

I am quite new to cypress , but having this functionality will be significantly better.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

bahmutov avatar Mar 03 '19 13:03 bahmutov

Thanks @bahmutov .

One more thing I would like to mention here , The link that I quoted , it runs paraterized test using for loop, it means that essentially , on outer context , this will be a single test case , not like separate test cases for separate test data as it is in testNG.

yogitthakral avatar Mar 03 '19 16:03 yogitthakral

@yogitthakral I want to implement similar logic in my new project requirement. In current one, we are using dataprovider(excel) in Selenium Java. We are going to use data driven framework for Cypress and Read test data from excel file. I am new to Cypress. Can you please help me.

Thanks, Sushant

sushantlokhande avatar Jan 08 '20 14:01 sushantlokhande

If you're currently using an Excel sheet, I think you could just convert your files to .json and use the "fixtures" feature of cypress to use your data within the tests.

If you need a Dynamic implementation you'll probably need to do a few more things.

mrpicklez70 avatar Jan 08 '20 15:01 mrpicklez70

@mrpicklez70 Thanks for your inputs.

The situation here is.. we are migrating from existing automation framework written in Selenium+Java to new automation framework in Cypress..

In old framework we used to read test data from multiple data tables mentioned in spread sheet. We are interested in knowing is there anyway we can directly use excel sheet in cypress automation.

We dont need dynamic Xls.. Our sheet is static in execution time..

sushantlokhande avatar Jan 08 '20 16:01 sushantlokhande