0

I am getting an error when I try to click each of the pages one by one in the following way:

I have tried using the .click function of puppeteer but it gives me the error: Error: Execution context was destroyed, most likely because of a navigation.

const aTags= await page.$$('#someId > a')
for (const aTag of aTags) {
   await aTag.click();
   //Do stuff
   page.goto(url); //this goes back to the initial page with the list of URLs
}

Would like to click the links one by one and return to the previous page

pam
  • 113
  • 1
  • 10
  • Possible duplicate of [Puppeteer Execution context was destroyed, most likely because of a navigation](https://stackoverflow.com/questions/55877263/puppeteer-execution-context-was-destroyed-most-likely-because-of-a-navigation) – Thomas Dondorf Jun 18 '19 at 05:33

1 Answers1

1

well if you go to the new page by clicking on the first link , you cant click on the rest of them ... bcuz you're not in the links page anymore just collect all the links into an array ... just use another function to open the links

for (const aTag of aTags) {
    let  href = await page.evaluate(el => el.getAttribute('href'), aTags);
    await open_links(href);
}



async function open_links( url ){
  // open new tab with the url 
}
hretic
  • 999
  • 9
  • 36
  • 78