Newbie here. Experimenting with puppeteer. I have my HTML as given below
<html>
<div id="container">
<span >
Parent Text
<sup name="20">Child Text</sup>
</span>
<span >
Parent Text
<sup name="20">Child Text</sup>
</span>
<span >
Parent Text
<sup name="20">Child Text</sup>
</span>
</div>
</html>
JS File
const list = await page.evaluate(() => {
const spans = document.getElementsByTagName("span")[0];
let data=[];
for (var i = 0; i < spanEntity.children.length; ++i){
if(spanEntity.children[i].innerText ==="Child Text"){
data.push(spans.innerText);
}
}
})
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!!.