title: How to save a variable/text to use later in Cypress test?
body: <p>The cypress docs(<a href="https://docs.cypress.io/guides/core-concepts/variables-and-aliases.html#Elements" rel="noreferrer">https://docs.cypress.io/guides/core-concepts/variables-and-aliases.html#Elements</a>) are pretty unclear on how alias and variables can be used to store information during a test.</p>
  <p>I'm trying to store the text of a div on one page to use later, for example:</p>
  <pre><code>// let vpcName;
  it('Store current name to use later', () =&gt; {
    // save name for later use - doesn't work
    // cy.get('#value').then(elem =&gt; {
    //   vpcName = Cypress.$(elem).text;
    // });
  
    // using alias - also doesn't work
    cy.get('#value')
      .invoke('text')
      .as('vpcName');
  });
    
  it('Use previous value to return to correct page', () =&gt; {
    cy.contains(this.vpcName).click();
  });
  </code></pre>