This is my code:
<v-select
label="label"
v-model="ccRcode"
ref="ccRcode"
:items="getData"
item-text="descWithCode"
item-value="code"
value="{ ccRcode }"
data-test='test'
></v-select>
This is my code:
<v-select
label="label"
v-model="ccRcode"
ref="ccRcode"
:items="getData"
item-text="descWithCode"
item-value="code"
value="{ ccRcode }"
data-test='test'
></v-select>
Assuming the item you want to select has the text "My Option", you can do:
cy.get("[data-test=test]").parent().click()
cy.get(".v-menu__content").contains("My Option").click()
The first line opens the dropdown, and the second selects the item.
v-select
with a more specific selector. –
Tillis within()
block. To get past this, you can use Cypress.$()
(see github.com/cypress-io/cypress/issues/6666) –
Bolt .v-list-item__content
in my case as @entorb suggests –
Kashmiri Try:
cy.get('[data-test=test]').type('valueNameGoesHere{enter}', {force: true})
We had the same issue with the respective the component. The fix we found is the following:
cy.get('#selectID').click().trigger('mousedown'); // this makes sure the select will stay open
2 options here, depends on if you have a wrapper for the options:
cy.get('#selectOptionsWrapper').contains('yourOption').click();
If you don't have a wrapper then just use contains:
cy.contains('yourOption').click();
Hope this will help others. Cheers!
I needed a slight modification of @benoit-blanchon's solution: .v-list-item__content
instead of .v-menu__content
:
cy.get('#my-select-identifier').parent().click()
cy.get(".v-list-item__content").contains("My Option").click()
Note: The last line of the solution by @robert-pop is a bit dangerous, since it performs a full page search, that can lead to problems if "My Option" appears somewhere else on the page.
This might be useful if you are using Vuetify.
v-select
with normal dropdown:
cy.get('[data-test="test"]').click();
cy.get('.v-list-item').contains('option').click();
v-select
with checkboxes in the dropdown:
cy.get('[data-test="test"]').click();
cy.get('[type="checkbox"]').first().check(); // check the first option
Use cy.get('[type="checkbox"]').check()
if you want to check all the options.
© 2022 - 2025 — McMap. All rights reserved.
cy.get("[data-test=test]").select("valueNameGoesHere");
? – Melanoid