Reputation: 11991
How can I select the dropdown
values using Cypress, it is build on angular page. By default the select field is displaying as below. First option click on the drop down but not value, I have tried eq(1), eq(2)..but not working yet.
I have tried the below options in cypress but these are not working;
Option : 1
cy.get('.mat-select-value > span').eq(0).then((option)=>{
cy.wrap(option).eq(0).click();
})
Option 2:
cy.get('.mat-select-value > span').contains("Phase 4 - Boond ").click();
// Attached the html:
Upvotes: 4
Views: 8312
Reputation: 211
Sometimes the click()
doesn't work as you would expect, in this case you can also try the trigger('click')
for the option selection.
like:
cy.get('your-selector').trigger('click')
Upvotes: 4
Reputation: 3741
you might want to try this:
cy.get('.mat-select-value > span').eq(0).click() // to open the drop down
cy.get('.mat-option').contains('Phase 4 - Boond').click() // to click the actual option
Upvotes: 4