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 AnswersCustom commands in Cypress
Custom commands are those commands that are created by users. These commands are stored in support/commands.js file.
Cypress.Commands.add("login", (userid, password) => {
//login to app
cy.get("input[type='userid']").type(userid);
cy.get("input[type='pass']").type(password);
cy.contains("Login").click();
});
Once the custom command is created, you can invoke it as shown in below example.
describe('Softpost Test', function () {
// test case
it('Book flight', function (){
cy.visit("https://www.booking.com/login");
cy.login('123','xyz')
});
});
Web development and Automation testing
solutions delivered!!