Reputation: 2076
All the docs seem to be explaining how to select a value in a drop-down, but I need to assert that a specific value is selected, without making any changes. I'm new to Cypress, so haven't been able to figure it out yet.
I tried cy.get('.selector').contains('expected string');
but the test fails with this error message --
expected <.selector> to have value 1st of the month after 60 days, but the value was ''
and Cypress.IO Select Drop Down didn't help either.
Fwiw, the selector is Vuetify's v-select
Any advice?
Upvotes: 2
Views: 3728
Reputation: 461
Assuming:
<select><option value="Alice">Bob</option> ... </select>
In a cypress test you can write:
cy.get('select').select('Bob').should('have.value', 'Alice')
Upvotes: 3
Reputation: 1
Assume:
Bob ...
In a cypress test you can write:
cy.get('select').select("Alice");
cy.get('select').find('option[value="Alice"]').should("be.selected");
Upvotes: 0