Complete the code to clear the input field with id 'username'.
cy.get('#username').[1]()
The cy.clear() command clears the value of an input field. Here, it clears the input with id 'username'.
Complete the code to clear the input field with class 'email-input'.
cy.get('.email-input').[1]()
cy.clear() empties the input field. Here, it clears the input with class 'email-input'.
Fix the error in the code to clear the input field with name 'password'.
cy.get('input[name="password"]').[1]()
The correct command to clear an input field is clear(). Using 'type' or others will not clear the field.
Fill both blanks to clear the input field with id 'search' and then type 'Cypress'.
cy.get('#search').[1]().[2]('Cypress')
First, clear() empties the input. Then, type('Cypress') enters the text.
Fill all three blanks to clear the input with class 'input-field', type 'Hello', and then assert it has the correct value.
cy.get('.input-field').[1]().[2]('Hello').should('[3]', 'Hello')
We clear the input, type 'Hello', then check it has the value 'Hello' using have.value.