0
0
Cypresstesting~10 mins

Cypress.Commands.add() - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a custom Cypress command named 'login'.

Cypress
Cypress.Commands.add('[1]', (email, password) => {
  cy.get('#email').type(email);
  cy.get('#password').type(password);
  cy.get('button[type=submit]').click();
});
Drag options to blanks, or click blank then click option'
Aclick
Bvisit
Ctype
Dlogin
Attempts:
3 left
💡 Hint
Common Mistakes
Using an existing Cypress command name like 'click' or 'type' instead of a new custom name.
Forgetting to put the command name in quotes.
2fill in blank
medium

Complete the code to call the custom command 'login' with email and password.

Cypress
cy.[1]('user@example.com', 'mypassword');
Drag options to blanks, or click blank then click option'
Avisit
Blogin
Ctype
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using built-in commands like 'visit' or 'click' instead of the custom command name.
Forgetting to call the command on cy.
3fill in blank
hard

Fix the error in the custom command definition by completing the missing part.

Cypress
Cypress.Commands.add('login', (email, password) => {
  cy.get('#email').[1](email);
  cy.get('#password').type(password);
  cy.get('button[type=submit]').click();
});
Drag options to blanks, or click blank then click option'
Atype
Bclick
Cvisit
Dshould
Attempts:
3 left
💡 Hint
Common Mistakes
Using click instead of type on input fields.
Using visit which is for navigation, not typing.
4fill in blank
hard

Fill both blanks to create a custom command 'fillForm' that types name and email.

Cypress
Cypress.Commands.add('[1]', (name, email) => {
  cy.get('#name').[2](name);
  cy.get('#email').type(email);
});
Drag options to blanks, or click blank then click option'
AfillForm
Bclick
Ctype
Dvisit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'type' to enter text.
Using an unrelated command name.
5fill in blank
hard

Fill all three blanks to add a custom command 'submitForm' that fills username, password, and clicks submit.

Cypress
Cypress.Commands.add('[1]', (username, password) => {
  cy.get('#username').[2](username);
  cy.get('#password').[3](password);
  cy.get('button[type=submit]').click();
});
Drag options to blanks, or click blank then click option'
AsubmitForm
Btype
DfillForm
Attempts:
3 left
💡 Hint
Common Mistakes
Using different methods like 'click' instead of 'type' for inputs.
Using a wrong command name.