title: Cypress: .each loop to find element that has value
body: <p>There ought to be a better way of doing this, but I can't find it.
  There are a number of elements with the same selector on the page. Only the value property differs. Controls are created dynamically, so I can't pin them down any more precisely.</p>
  
  <p>I am searching for an element with a specific value, using Cypress . HTML looks like this:</p>
  
  <pre><code>&lt;input type="button" value="Save" data-cy-component="button-button" class="btn form-control btn-info"&gt;
  </code></pre>
  
  <p>When I find it I want to click it &amp; jump out of the loop.</p>
  
  <p>This is what I have:</p>
  
  <pre><code> const buttonButton = '[data-cy-component=button-button]';
   cy.get(buttonButton).each(($el, index, $list) =&gt; {
    cy.log(`index: ` + index);
    if (index === 5) {
      cy.wrap($el)
        .should('have.value', 'Save')
        // Click Save button.
        .click();
    }
  });
  </code></pre>
  
  <p>This method works, but seems vulnerable. If my Save button is no longer the 5th (or 6th) element, the test will fail. Is there a way I can test it with an IF rather than a SHOULD?</p>