Complete the code to visit the homepage in Cypress.
cy.[1]('https://example.com')
The visit command loads a page in Cypress. Other commands like click or type interact with elements but do not load pages.
Complete the code to assert that a button with id 'submit' is visible.
cy.get('#submit').[1]('be.visible')
The should command is used to make assertions in Cypress. Here, it checks if the button is visible.
Fix the error in the code to correctly select all list items inside a <ul> with class 'menu'.
cy.get('ul.menu [1] li')
The > selector selects direct children. To get all li inside ul.menu, use ul.menu > li.
Fill both blanks to create a reusable function that checks if an element with given selector contains expected text.
function checkText(selector, text) {
cy.get([1]).should([2], text)
}The function uses the selector parameter to get the element. The assertion uses should('contain', text) to check if the element contains the text.
Fill all three blanks to create a test that visits a page, types in an input, and asserts the input value.
describe('Input test', () => { it('types and checks input', () => { cy.[1]('https://example.com/form') cy.get('#name').[2]('Alice') cy.get('#name').should([3], 'Alice') }) })
The test visits the page with visit, types 'Alice' into the input with type, and asserts the input's value with should('have.value', 'Alice').