In my Cypress test I want to select one value from a dropdown list but I have to wait random time to have this value loaded in this dropdown (this one is populated when another and previous dropdown value is selected)
I tried many things like :
- cy.click use on the parent element of the "select" with timeouts but ko
- cy.select use with timeout and force click options but ko too
- cy.request to wait for the WS responses but makes the code unnecessarily complex and doesn't work too
- the best try I have currently is this one :
cy.get('select[id="form_chantier:ste-menu"]')
.should(($optionsArray) => {
expect($optionsArray.get(0)).to.have.property('childElementCount', 172)
})
.then(() => {
cy.get('select[id="form_chantier:ste-menu"]').select('01 SNEF')
})
cy.get('select[id="form_chantier:sce-menu"]')
.should(($optionsArray) => {
expect($optionsArray.get(0)).to.have.property('childElementCount', 252)
})
.then(() => {
cy.get('select[id="form_chantier:sce-menu"]').select('01 SIEGE')
})
It works for the first select but the second it's ko because when the first dropdown value is selected the seconde dropdown values data are not loaded fast. How can I solve this problem please ?