title: Puppeteer Getting the text within all the elements with <span> tag in DOM only if it has a <sup> child tag
body: <p>Newbie here. Experimenting with puppeteer. I have my HTML as given below</p>
  <pre><code>&lt;html&gt;
  &lt;div id=&quot;container&quot;&gt;
        &lt;span &gt;
          Parent Text
          &lt;sup name=&quot;20&quot;&gt;Child Text&lt;/sup&gt;  
        &lt;/span&gt;
        &lt;span &gt;
         Parent Text
          &lt;sup name=&quot;20&quot;&gt;Child Text&lt;/sup&gt;  
        &lt;/span&gt;
        &lt;span &gt;
          Parent Text
          &lt;sup name=&quot;20&quot;&gt;Child Text&lt;/sup&gt;  
        &lt;/span&gt;
  
      &lt;/div&gt;
  &lt;/html&gt;
  </code></pre>
  <p>JS File</p>
  <pre><code>const list = await page.evaluate(() =&gt; {
       const spans = document.getElementsByTagName(&quot;span&quot;)[0];
       let data=[];
      for (var i = 0; i &lt; spanEntity.children.length; ++i){
        if(spanEntity.children[i].innerText ===&quot;Child Text&quot;){
          data.push(spans.innerText);
        }
      }
  })
  </code></pre>
  <p>This works for first span element. But how can I do this for all the span elements in DOM. I know we can use querySelectorAll to check for all span elements in DOM. But I'm not aware how to check the for child nodes .Any help will be greatly appreciated. Thank You in advance!!.</p>