title: Cypress click() failed because this element is detached from the DOM in iteration
body: <p>I try to test my <strong>Single Page Application</strong> with cypress. <br>
  The first page has multiple buttons as <strong>anchor tags</strong> which direct you to the second site(Angular routing). <br>
  On the second site i have a &quot;back&quot; button.
  <br>So i want my test to click on a button, wait for the second site to appear, click on the back and repeat this for all remaining buttons.</p>
  <p>This is my cypress test:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>describe('Select products', function () {
      before(() =&gt; {
          cy.visit('http://localhost:4200/')
      })
      it('Clicking through products', function () {
      
          // getting each anchor to click 
          cy.get('a[data-cy=submit]').each(
              ($el) =&gt; {
              
                  // click to get on next site
                  cy.wrap($el).click()
                  
                  // click to go back
                  cy.contains('go back').click()
              }
          )
      })
  })</code></pre>
  </div>
  </div>
  </p>
  <p>It works fine for the first run(<strong>get all buttons =&gt; click the first =&gt; go back</strong>) <br> but after getting back on the start site before clicking the next button cypress throws an error:</p>
  <p><a href="https://i.stack.imgur.com/5gibq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5gibq.png" alt="enter image description here" /></a></p>
  <p>Can someone help me with this?
  Thanks for any help!</p>