Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Cypress – How to handle dropdown

Category: Cypress
//Select the values from the Select dropdown
//First locate the dropdown and then the select the value
cy.get('.dropdown').select('India').should('have.value', 'India')

//Select the value from the dynamic dropdown by entering the value
cy.get('.dynamic-dropdown').click()
cy.get('.dropdown.text').type('India').type('{enter}')

//Verify the default selected value in dropdown
cy.get('.dropdown').should('have.text', 'India')

Leave a Reply

Your email address will not be published. Required fields are marked *