Cypress handles static dropdowns with the
help of the select() command.
For a static dropdown, the tag name of the element should be <select> and
its child elements should have the tag name <option>.
We can select values by passing texts or indexes.
In this blog,
we will see how we can unselect all dropdown values by passing an empty array.
Before version 8.6.0,
we would get an error if an empty array was passed into cy.select().
Consider the following snippet to understand the usage better.
It follows the existing pattern that passing an array into cy.select() will unselect the other options.
With the updated Cypress 8.6.0,
we can use cy.select() to clear any selected options in a multi-value select.
an error would be thrown if an empty array was passed into cy.select().