← Back to library
Cypressformsbeginnerv10+

Select from a dropdown

Select a <select> option by text, value, or index.

1it('selects a dropdown option', () => {
2  cy.visit('/settings');
3
4  // By visible text
5  cy.get('select[name="country"]').select('Egypt');
6
7  // By value
8  // cy.get('select[name="country"]').select('EG');
9
10  // By index (0-based)
11  // cy.get('select[name="country"]').select(2);
12
13  cy.get('select[name="country"]').should('have.value', 'EG');
14});
#select#dropdown#forms