for(let i = 2; i<=19; i++) {
let arr = await page.evaluate(() => {
let text = document.querySelector(`body > main > div > section > div:nth-child(${i})`).innerText
return text
})
console.log(arr)
}
Error [ReferenceError]: i is not defined
for(let i = 2; i <= 19; i++) {
let arr = await page.evaluate((index) => {
let text = document.querySelector(`body > main > div > section > div:nth-child(${index})`).innerText;
return text;
}, i);
console.log(arr);
}