title: Cypress: How to get Href attribute value, redirect and match the URL with value
body: <ul>
  <li>Please open the image <a href="https://i.stack.imgur.com/oCYta.jpg" rel="nofollow noreferrer">HTML</a></li>
  </ul>
  
  <p>I want to get the value (URL) of the first href for this class (.grid-item) then navigate to the respective href link and verify the value (URL) with the current page's URL.</p>
  
  <p>How can I achieve that using Cypress?</p>
  
  <p>Code:</p>
  
  <pre><code>  selectStackup = () =&gt; {
      cy.get(".grid-item")
        .eq(1)
        .invoke("attr", "href")
        .then(href =&gt; {
          cy.visit(href);
        });
    };
  </code></pre>
  
  <p><strong>Error:</strong>
  - CypressError: cy.visit() must be called with a URL or an options object containing a URL as its 1st argument</p>