I am currently testing a new feature where a button will only appear for the user to click after they have completed another action.
Before proceeding with the action, I am verifying if the button exists:
cy.get('span')
.contains('Select')
.parent('button')
.should('not.exist');
However, after completing the action, I am having difficulty finding the same button. Does anyone know how to achieve this in Cypress?
Below is my complete code:
cy.get('span')
.contains('Select')
.parent('button')
.should('exist');
/* eslint-disable */
describe('Workgroup Switch', () => {
beforeEach(() => {
cy.visit('/login');
cy.get('input[id="username"]').type('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="42202d313102273a232f322e276c">[email protected]</a>');
cy.get('input[id="password"]').type('password');
cy.get('button[id="login-button"]').click();
cy.url().should('include', '/offers/workgroup');
});
it('switch workgroup', () => {
cy.get('span')
.contains('Select')
.parent('button')
.should('not.exist');
cy.get('.v-overlay__scrim').click();
cy.get('.text-h6')
.contains('Workgroup #1')
.parent()
.parent()
.click();
cy.contains('Make this my default workgroup');
cy.get('span')
.contains('Select')
.parent('button')
.should('exist');
});
});