Skip to content

Instantly share code, notes, and snippets.

@RockChild
Created August 14, 2020 05:33
Show Gist options
  • Save RockChild/90b5cd3fec1f85c52d4dd976f3f1ea12 to your computer and use it in GitHub Desktop.
Save RockChild/90b5cd3fec1f85c52d4dd976f3f1ea12 to your computer and use it in GitHub Desktop.
// You can keep it inside of the test but it's preferable to store such commands in cypress/support/commands.js
// or create a separate file for related commands e.g. cypress/support/buttons.js
// but don't forget to import it in cypress/support/index.js
Cypress.Commands.add('getLoginButton', (label) => {
switch(label) {
case 'login':
return cy.get(loginBtnSelector);
case 'register':
return cy.get(registerBtnSelector);
}
});
//Use it in test
it('should click on login button', () => {
cy.getLoginButton('login').click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment