Complete the code to find an element containing the text 'Submit'.
cy.[1]('Submit')
cy.get() which selects by selector, not text.cy.click() which performs a click, not a search.The cy.contains() command finds an element with the given text.
Complete the code to find a button element containing the text 'Cancel'.
cy.[1]('button', 'Cancel')
cy.get() with two arguments, which is invalid.cy.find() which requires a parent element.cy.contains(selector, text) finds an element matching the selector with the given text.
Fix the error in the code to correctly find a link containing 'Home'.
cy.[1]('a', 'Home')
cy.get() with :contains() selector causes errors.cy.click() instead of a query command.cy.get() does not support jQuery :contains selector. Use cy.contains() instead for text matching.
Fill both blanks to find a div containing the exact text 'Welcome'.
cy.[1]('div').[2]('have.text', 'Welcome', { matchCase: true })
cy.contains('div', { matchCase: true }, 'Welcome').cy.find() without a parent element.First, cy.get() selects all div elements. Then should('have.text', 'Welcome', { matchCase: true }) asserts the exact text with case sensitivity.
Fill all three blanks to find a button containing 'Save' and click it.
cy.[1]('button', [2]).[3]()
cy.get() with text argument, which is invalid.click() after finding the element.cy.contains('button', 'Save') finds the button with text 'Save', then click() clicks it.