0
0
Cypresstesting~10 mins

Why login handling speeds up test suites in Cypress - Test Your Understanding

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

Complete the code to visit the login page in Cypress.

Cypress
cy.[1]('/login')
Drag options to blanks, or click blank then click option'
Aclick
Bvisit
Cget
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using click instead of visit to open a page.
2fill in blank
medium

Complete the code to fill the username input field.

Cypress
cy.get('input[name="username"]').[1]('myUser')
Drag options to blanks, or click blank then click option'
Atype
Bclick
Cselect
Dcheck
Attempts:
3 left
💡 Hint
Common Mistakes
Using click or select instead of type.
3fill in blank
hard

Fix the error in the code to submit the login form.

Cypress
cy.get('form').[1]()
Drag options to blanks, or click blank then click option'
Asubmit
Bclick
Ctype
Dcheck
Attempts:
3 left
💡 Hint
Common Mistakes
Using click on the form instead of submit.
4fill in blank
hard

Fill both blanks to create a custom command for login that speeds up tests.

Cypress
Cypress.Commands.[1]('login', (username, password) => {
  cy.request('POST', '/api/login', { username: username, [2]: password })
})
Drag options to blanks, or click blank then click option'
Aadd
Bsend
Cpass
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using send or post instead of add for command creation.
5fill in blank
hard

Fill all three blanks to use the custom login command and speed up the test suite.

Cypress
describe('Dashboard tests', () => {
  beforeEach(() => {
    cy.[1]('login', 'user1', [2])
    cy.[3]('/dashboard')
  })
  it('shows welcome message', () => {
    cy.contains('Welcome').should('be.visible')
  })
})
Drag options to blanks, or click blank then click option'
Alogin
B'pass123'
Cvisit
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using click instead of visit to load the page.