i am trying to set id’s to all img tags of a page, my loop runs its iterations completely but some of the img tags doesn’t get the id’s as can be seen in the below image
here is my code
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
],
});
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 10000 })
await page.goto(url, {
waitUntil: 'networkidle2',
timeout: 0,
});
await page.evaluate(() => {
const images = document.getElementsByTagName('img') || []
for (let i = 0; i < images.length; i++) {
document.getElementsByTagName('img')[i].id = `${i}`
}
})
Am i missing anything? any help would be highly appreciated