Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select value from drop down using cypress?

Tags:

cypress

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()
like image 863
user2345 Avatar asked Oct 24 '25 19:10

user2345


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()
like image 57
Seeker Avatar answered Oct 26 '25 13:10

Seeker


Have a look at this. Gives a good explanation as well.

select dropdownlist item using cypress

Otherwise you can just get it by css selector, xpath or you can do cy.contains

like image 21
ItsNotAndy Avatar answered Oct 26 '25 11:10

ItsNotAndy



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!