Complete the code to define a class for the login page in Cypress.
class LoginPage { visit() { cy.[1]('https://example.com/login') } }
The cy.visit() command is used in Cypress to open a URL. The other options are not valid Cypress commands.
Complete the code to select the username input field using a CSS selector.
getUsernameField() {
return cy.get('[1]')
}The ID selector #username is the most specific and common way to select the username input. The other options may not match the element correctly.
Fix the error in the method that types the password in the password field.
typePassword(password) {
cy.get('#password').[1](password)
}The correct Cypress command to enter text into an input field is type(). Other options are not valid Cypress commands.
Fill both blanks to create a method that clicks the login button and asserts the URL contains '/dashboard'.
clickLogin() {
cy.get('[1]').click()
cy.url().[2]('include', '/dashboard')
}expect instead of should for Cypress assertions.The login button is selected by its ID #loginBtn. The assertion uses should('include', ...) to check the URL contains '/dashboard'.
Fill all three blanks to create a test that uses the LoginPage object to visit, enter credentials, and click login.
const loginPage = new LoginPage() loginPage.[1]() loginPage.getUsernameField().[2]('user1') loginPage.typePassword('pass123') loginPage.[3]()
The test first calls visit() to open the page, then types the username with type(), and finally clicks login with clickLogin(). The submit method does not exist here.