worried-shampoo-96177
03/08/2023, 7:12 AMgray-kilobyte-89541
03/08/2023, 11:37 AMenough-truck-68085
03/08/2023, 3:35 PM.within
The display element you are trying to validate is outside of the input element but you are forcing the validation to look within the input...where the display text doesn't exist.
it('this works', () => {
cy.visit('https://demo.seleniumeasy.com/basic-first-form-demo.html')
const messageTxt = 'hello'
cy.get('[id="get-input"]').within(() => {
cy.get('[type="text"]').type(messageTxt)
cy.contains('button', 'Show Message').click({ force: true })
})
cy.get('[id="display"]').should('have.text', messageTxt)
})
Move the validation outside of the within and that will work.
Edit: Also your url shouldn't include %22. Remove that from the visitgray-kilobyte-89541
03/08/2023, 4:12 PMworried-shampoo-96177
03/09/2023, 1:21 PMworried-shampoo-96177
03/09/2023, 1:22 PM