Home
Basics
Introduction Environment Setup Cypress Components First Test Running Tests Reports Element Identification GUI interaction Cypress Hooks Cypress Fixtures Integration with CI serversAdvanced
Page Object Model Custom Commands Intercepting Requests Backend Testing Interview Questions and AnswersCypress Fixtures
Cypress fixtures can be used to store test data. Fixture files are stored in fixtures directory. Here is a example.json which stores the firstName and lastName.
{
"firstName": "Sagar",
"lastName": "Salunke"
}
We are reading firstName from above file and then entering this value in UI.
describe('Softpost Test', function () {
before(function(){
//load fixture data
cy.fixture('example').then(function(data){
this.data=data
})
})
it('Use fixture data', function (){
cy.visit("https://softpost.org/selenium-test-page")
cy.get('#fn').type(this.data.firstName)
});
});
Web development and Automation testing
solutions delivered!!