describe('Button properties test', () => {
beforeEach(() => {
cy.visit('https://example.com/sample-page')
})
it('should verify button visibility, enabled state, and text using should() with chainers', () => {
cy.get('#submit-btn')
.should('be.visible')
.and('be.enabled')
.and('have.text', 'Submit')
})
})The test visits the sample page before each test to ensure a fresh state.
It locates the button using its id #submit-btn, which is a stable selector.
The should() command is used with multiple chainers: be.visible to check visibility, be.enabled to check if the button is enabled, and have.text to verify the button's text content.
This chaining makes the test concise and easy to read.
Cypress automatically waits for elements to appear, so no explicit waits are needed.