How to select value from drop down using cypress?

Viewed 3053

Here I am using cypress tool for automation. How to write code for dropdown menu

drop down with search box and select button

Here is the HTML code html code

I just done like this way but its not working

cy.get('.dropdown-heading-dropdown-arrow').click()
cy.get('#0').click()
2 Answers

After dropdown opens search for the option with required text.

Not sure which selector might work for you, either role or .MuiMenuItem-root looks best, or try just getting any element with the text

cy.get('.dropdown-heading-dropdown-arrow').click()

cy.contains('[role="option"]', 'Select All')      
  .click()

// or

cy.contains('.MuiMenuItem-root', 'Select All')      
  .click()

// or

cy.contains('Select All')
  .click()
Related