I want to read data from a particular cell of my excel sheet and then use that data in my cypress tests. The file name is ‘qaautomation.xlsx’ and sheet name is ‘Input’ and I want to read data from cell B2. I have written the following code to access the value
/// <reference types ="cypress" />
var xlsx = require ("xlsx");
var workbook= xlsx.readFile("qaautomation.xlsx");
var worksheet= workbook.Sheets["Input"];
var cellB2value= 'B2';
var cellB2=worksheet[cellB2value];
var cellB2_value=(cellB2.v);
Code written below is where the value would be used.
describe('Typing the address', function(){
it ('should open the link', function(){
cy.visit(cellB2_value) //here comes the value from cell B2
})})
When I run the above code I get the following error
The following error originated from your test code, not from Cypress.
> _fs.readFileSync is not a function
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.
Check your console for the stack trace or click this message to see where it originated from.
Is there any way to remove this error?
move the functionality causing that into
cypress/support/
such as incommands.js
This is a problem with how the XLSX read function deals with webpack and the browser’s security feature to not access the file system directly.
You’ll need to read the file via an ajax call and then ‘read’ it into xlsx that way. There’s a demo here:
https://github.com/SheetJS/sheetjs/tree/master/demos/xhr
propecia for women – http://finasteridepls.com/ finasteride reviews
tadalafil prescription online – tadalafil plus sildenafil generic tadalafil 20mg
Sjqqsj – http://virviaga.com/ brand viagra
Ldoayr – viagra cialis generique Kflvti dcwuwf
Vmfzjr – generic lasix Odluoy aymwat
Cbpigs – cialis 5mg price south africa Nfzhlc lmtivc
Xrdjxy – best prices for viagra Syjbzz nnjllf
Jwmlfw – acheter viagra kamagra en ligne Dhlblp ykdeys
Urnypb – how to buy silagra online in usa Ekbahq yccinm