title: Cypress get the ID of some element
body: <p>I am trying to obtain the ID of some element in Cypress. Because it's ID randomly changes (yes it is strange but it is angular).</p>
  <p>E.g. I have a <code>&lt;button id=&quot;dropdown-1&quot; class=&quot;someclass&quot;&gt;&lt;span&gt;Click here&lt;/button&gt;</code></p>
  <p>As I can't rely on that ID, because after I do some actions on the page it becomes to dropdown-2 etc., I want to know, what is the current ID name.</p>
  <p>I tried something like:</p>
  <pre><code>cy.get('button &gt; span').contains('Click here').find(&quot;id&quot;);
  </code></pre>
  <p>but seems that is not the correct way.</p>
  <p>I also tried:</p>
  <pre><code>  cy.get('button &gt; span').contains('Click here')
    .invoke('attr', 'id')
  </code></pre>
  <p>this works not as well.</p>