I have a table for emails with "primary" radiobuttons column which means only one of them could have class .checked. How can I check this with Cypress?
I tried this but it's not working for classes since it checks if all the elements in the column to have this class.
P.S I'm using TypeScript and React. Each row is rendered separately
it("check if rest of the emails' primary setting are set to false", () => {
cy.get('td:nth-child(2)')
.should('not.have.class', 'checked')
.should('have.length', 1);
CodePudding user response:
Try the jQuery :checked selector
cy.get('td:nth-child(2):checked')
.should('have.length', 1)
CodePudding user response:
cy.get('td:nth-child(2) .checked').should('have.length', 1);