← Back to library
Cypressformsbeginnerv10+
Clear and type into an input field
Clear an existing value and type a replacement — the standard edit-form pattern in Cypress.
1it('updates the email address field', () => {
2 cy.visit('/account');
3
4 // .clear() empties the field, .type() then populates it fresh
5 cy.get('[name="email"]')
6 .should('have.value', 'old@example.com')
7 .clear()
8 .type('new@example.com')
9 .should('have.value', 'new@example.com');
10
11 cy.get('[type="submit"]').click();
12 cy.contains('Email updated').should('be.visible');
13});#clear#type#input#edit#fill