Reputation: 85
Below is the Excel from which i need 'SIP' data '37046654'
enter image description here enter image description here
I have tried below cypress code but it is failing as it is expecting all the data in the excel-sheet
Cypress Code:
describe('API Testing with Cypress', () => {
it('Validate the header', () => {
responsebodydata = cy.readFile('C:/Users/backNew.csv').should('eq','37046654')
cy.log (responsebodydata)
})
})
Assertion result: Failed with timeout by following output:
expected 'SIP\tAsset Class\tSector\tObservations\tCDP Proximity\r\n37046789\tUP1G\tRetail\t1\t100\r\n37046654\tUG8G\tRetail\t1\t0' to equal '37046ADD'
Can anyone give some idea how can i get / check '37046654' exist in the excel-sheet or not
Upvotes: 1
Views: 701
Reputation: 11
Complete Working Code -
<reference types="Cypress" />
describe('API Testing with Cypress', () => {
var responsebodydata
it('Validate the header', () => {
responsebodydata = cy.readFile('C:/Users/sharma.al/backNew.csv').then((response)=> {
responsebodydata = response.body
cy.log(responsebodydata)
responsebodydata = cy.readFile('C:/Users/sharma.al/backNew.csv').should('contains','37046654')
})
})
})
Upvotes: 0
Reputation: 8692
If you want just check that the 37046654
number is present in the backNew.csv
file - use the contains
.
responsebodydata = cy.readFile('C:/Users/backNew.csv').should('contains','37046654')
Upvotes: 2