Cypress - Element Interactions
You want to check multiple checkboxes with the same name attribute
colors and values red and blue. Which code correctly checks both?colors and values red and blue. Which code correctly checks both?To check multiple checkboxes with same name but different values, pass an array of values to check().
cy.get('input[name="colors"]').check(['red', 'blue']) correctly uses check(['red', 'blue']). cy.get('input[name="colors"]').check('red').check('blue') calls check twice but chaining like that is less efficient. cy.get('input[name="colors"]').check('red,blue') passes a string with comma which is invalid. cy.get('input[name="colors"]').uncheck(['red', 'blue']) unchecks instead of checking.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions