When the following build runs, I get the error "Error: Evaluation failed: ReferenceError: chunk is not defined" as a console response. In the next line, I can reach chunk[a] as console.log, but why can't I reach it in frame.evaluate?
const puppeteer = require('puppeteer');
const chunk= ["google.com","facebook.com","gmail.com","stackoverflow.com"];
(async () => {
for(var a=0;a<chunk.length;a++){
const browser = await puppeteer.launch({headless:false})
const page = await browser.newPage();
const iframeHandle = await page.$("frame[name='main']");
const frame = await iframeHandle.contentFrame();
console.log(chunk[a]);
await frame.evaluate(() => {
if(document.querySelector("#content > table").innerHTML.indexOf(chunk[a]) > -1){
console.log(chunk[a]);
}
});
}
})()
result : google.com Evaluation failed: ReferenceError: chunk is not defined