title: Creating a variable in a Cypress test to store text on a page in order to compare it against text on a different page
body: <p>I'm trying to create a variable in my cypress test that will allow me to store info from one web page for when I click a link and leave the page. I want to compare a word from this first page to a word on the second.</p>
  <pre><code>describe(&quot;Logged-in Item Page&quot;, () =&gt; {
  
   before(() =&gt; {
     cy.*login command*().then((*login stuff*) =&gt; {
       cy.website_login(*login info*);
     });
   });
   beforeEach(() =&gt; {
     cy.visit(Cypress.env(&quot;baseUrl&quot;) + &quot;*URL*&quot;)
   });
   
   it(&quot;Verify My Store opens&quot;, () =&gt; {
         return new Cypress.Promise(resolve =&gt; {
           cy.get(&quot;*selector*&quot;).then($value =&gt; {
             const storeName = $value.text().split(' ')[0];
             resolve(storeName);
           });
           cy.log(storeName)
         });
     });
  });
  </code></pre>
  <p>It is worth to mention that I tried putting var Storename; outside of this area and removing the var keyword inside to cy.get() part but still no luck. As well I tried doing const storeName instead.</p>