title: How to handle multiple tabs in cypress
body: <p>Im coding integration tests in a project with cypress. This is the flow in my projet:</p>
  <ul>
  <li>You click at a buy button of a projeto;</li>
  <li>When you click, open a new tab in checkout product</li>
  </ul>
  <p>Only this, click at a button and open a new tab with the checkout screen. But as we know, cypress dont have suport for multiple tabs, so how can i handle it? What is the way to open  this new url in the same tab?</p>
  <p>Important to highlight that this button is not wrapped by any <code>a</code> tag, its just a button that when I click has a <code>handleClick</code> that open a new tab and do other stuff. Because of this, none of these <a href="https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/testing-dom__tab-handling-links/cypress/integration/tab_handling_anchor_links_spec.js" rel="nofollow noreferrer">https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/testing-dom__tab-handling-links/cypress/integration/tab_handling_anchor_links_spec.js</a> solutions work for me.</p>
  <p>I already tried this:</p>
  <pre><code>      cy.stub(win, &quot;open&quot;)
          .callsFake((url, target) =&gt; {
            //@ts-ignore
            return win.open.wrappedMethod.call(win, url, &quot;_self&quot;);
            //@ts-ignore
          })
          .as(&quot;open&quot;);
      });
  </code></pre>
  <p>but no success.</p>