🛃24. Cypress Custom Commands
Cypress.Commands.add(function-name, func)
Cypress.Commands.add(function-name, opts, func)
Cypress.Commands.overwrite(function-name, func)Implementation of custom command
Cypress.Commands.add("userInput", (searchTxt) => {
//to input search text in Google and perform search
cy.get("input[type='text']").type(searchTxt);
cy.contains("Google Search").click();
});describe('Tutorialspoint Test', function () {
// test case
it('Test Case 6', function (){
// launch the application
cy.visit("https://www.google.com/");
//custom parent command
cy.userInput('Java')
});
});Last updated