# Select value by partial text via its index

  <option value="270">Green apples</option>
  <option value="381">Fresh oranges</option>
  <option value="718">Juicy melons</option>

How would we select the option with the text "melon"? We need to find it using a partial text match using the cy.contains (opens new window), then grab the index of the element among its siblings, and then use the index to select the option.

cy.get('select option')
  .then((index) => {
// confirm the selected value
cy.get('select').should('have.value', '718')

Watch the video Select An Option By Partial Text Match (opens new window).