title: Cypress get elements within specific path
body: <p>Automating some tests with Cypress, I've found this issue.</p>
  <p>We are asking many questions to the customers and these question will appear one-by-one depending on the previous answers. The next question (and for instance the kind of answer) will be unknown until it is shown. I leave this here as an example in which every 'div' (not 'rootDiv') is a question and they are only shown when the previous one has been responded.</p>
  <pre><code>    &lt;div class=&quot;rootDiv&quot;&gt;
          &lt;div class=&quot;type1&quot;&gt;
             &lt;div class=&quot;type1b&quot;&gt;
                &lt;button class=&quot;button1&quot;&gt;
                &lt;button class=&quot;button1&quot;&gt;
             &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;type2&quot;&gt;
             &lt;div class=&quot;type2b&quot;&gt;
                &lt;button class=&quot;button2&quot;&gt;
                &lt;button class=&quot;button2&quot;&gt;
                &lt;button class=&quot;button2&quot;&gt;
                &lt;button class=&quot;button2&quot;&gt;
             &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;type1&quot;&gt;
             &lt;div class=&quot;type1b&quot;&gt;
                &lt;button class=&quot;button1&quot;&gt;
                &lt;button class=&quot;button1&quot;&gt;
             &lt;/div&gt;
          &lt;/div&gt;
          .
          .
          .
         &lt;div class=&quot;typeX&quot;&gt;
             &lt;div class=&quot;typeXb&quot;&gt;
                &lt;button class=&quot;buttonX&quot;&gt;
                &lt;button class=&quot;buttonX&quot;&gt;
                &lt;button class=&quot;buttonX&quot;&gt;
                &lt;button class=&quot;buttonX&quot;&gt;
             &lt;/div&gt;
         &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  <p>So the issues I am facing are:</p>
  <ol>
  <li>Is there a way to access to the last 'div' within 'rootDiv', check its class and based on it click any of the buttons?</li>
  <li>Is there a way to get the 'text' written on the buttons of the last 'div'?</li>
  <li>Is there a way to have a list of elements (buttons in this case) and iterate through them?</li>
  </ol>
  <p>There are many options to solve it, the main problem relies on how to get to those elements</p>