Cypress: How do I deal with multiple select on the page

Created on 16 Apr 2019  路  14Comments  路  Source: cypress-io/cypress

On this page, I have 3 select classes. I want to enter the value for first select class(builidng Id) and the second (floorid) and third(calendar date). How can I do that?
image
cy.get('select').select('1').should ('have.value', '10056')

Most helpful comment

You can replace 'select' key for your element id, like this:

cy.get('floorid').select('1').should ('have.value', '10056')
https://docs.cypress.io/api/commands/select.html#Usage

or using the eq method, which enables you to get the desire index:
https://docs.cypress.io/api/commands/eq.html
cy.get('select').eq(0).select('1').should ('have.value', '10056')

All 14 comments

I get this error :CypressError: cy.select() can only be called on a single
cy.get('.cm-dropdown > .dropdown').click().contains('ul li > span','Zoetis').click({multiple:true})
cy.get('.selection-trigger').click().contains('ul li > span','Elk Grove').click({multiple:true})
I get below error message:
Timed out retrying: Expected to find content: 'Zoetis' within the element: and with the selector: 'ul li > span' but never did.

Could you share some code ? I need to see the structure of your elements to elaborate the query

Issues in our GitHub repo are reserved for potential bugs or feature requests, so I will be closing this issue. Comments are still allowed, so you can continue debugging if you like.

We recommend questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.

@mateosilguero : here the one for client:
image

@mateosilguero : this one is for site:
image

cy.get("select[name='UserID']").select('LName, FName')

Was this page helpful?
0 / 5 - 0 ratings