Cypress: Could not able to retrieve a specific dat

2019-07-28 08:45发布

问题:

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

回答1:

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')


标签: cypress