title: Cypress: How to Copy/Paste single text word from string to paste later
body: <p>I am new to stackoverflow so apologies if this is a bit all over the place but I can't seem to find any easy answer online for what seems like a pretty small task! :(</p>
  <p>I am trying to Copy some data from a pop-up, that says something like &quot;Congrats, Your Ref (REF1234) completed successfully&quot; (just the REF1234 part) and copy it to paste into another field on the next screen... This is what I have so far, which hopefully makes sense to someone...</p>
  <pre><code>export function addRefToThing() {    
    cy.get('[class=&quot;ref-success&quot;]').find(':selected').contains('REF').then(($clipboard) =&gt; {
      const copiedRef = $clipboard[0]._vClipboard.clipboardAction.text;
  
  // &lt;&lt;filler steps, moving around pages&gt;&gt; //
  
      webpage.RefNo().type(copiedRef)})
  </code></pre>
  <p>This is pretty much as far as I've been able to get and pulling my hair out ... Looks like it's getting caught up at <code>-find :selected</code> but not actually sure it's even copying the data I want...</p>
  <p>I'm pretty new to cypress so this is proving pretty confusing and if anyone has any good training material regarding this kind of request, that'd be awesome! Thanks in advance!</p>
  <p>HTML:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;notification-group&quot; style=&quot;width: 300px; bottom: 0px; right: 0px;&quot;&gt;
     &lt;span&gt;
        &lt;div data-id=&quot;1&quot; class=&quot;notification-wrapper&quot; style=&quot;transition: all 300ms ease 0s;&quot;&gt;
           &lt;div class=&quot;notification-template notification success&quot;&gt;
              &lt;div class=&quot;notification-title&quot;&gt;Successful&lt;/div&gt;
              &lt;div class=&quot;notification-content&quot;&gt;Ref (REF123456789) created successfully&lt;/div&gt;
           &lt;/div&gt;
        &lt;/div&gt;
     &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>