Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Cypress drop down select values are not happening

Tags:

cypress

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.

enter image description here

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:

enter image description here

like image 978
soccerway Avatar asked Oct 22 '25 16:10

soccerway


1 Answers

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
like image 52
Mr. J. Avatar answered Oct 24 '25 18:10

Mr. J.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!