Using Puppeteer to click main links and clicking sub-links?










0















Simplification :



I have a website with links.

After clicking on each link , it goes to a new page that I need to visit the links ( by clicking , not navigating).



Visualization :



enter image description here



I've managed to do 99% percent of the job:



(async () =>

const browser = await puppeteer.launch(headless: false);
const page = await browser.newPage();
let url = "https://www.mutualart.com/Artists";
console.log(`Fetching page data for : $url...`);
await page.goto(url);
await page.waitForSelector(".item.col-xs-3");
let arrMainLinks: ElementHandle = await page.$$('.item.col-xs-3 > a'); //get the main links

console.log(arrMainLinks.length); // 16


for (let mainLink of arrMainLinks) //foreach main link let's click it

let hrefValue =await (await mainLink.getProperty('href')).jsonValue();
console.log("Clicking on " + hrefValue);
await Promise.all([
page.waitForNavigation(),
mainLink.click(delay: 100)
]);

// let's get the sub links
let arrSubLinks: ElementHandle = await page.$$('.slide >a');

//let's click on each sub click
for (let sublink of arrSubLinks)

console.log('██AAA');

await Promise.all([
page.waitForNavigation(),
sublink.click(delay: 100)
]);
console.log('██BBB');

// await page.goBack()
break; // for now ...

break;



await browser.close();
)();


So where is the problem ?



It reaches the ██AAA

But it never reaches ██BBB



And I get an error :



 C:temppuppeterr1app>node server2.js
Fetching page data for : https://www.mutualart.com/Artists...
16
Clicking on https://www.mutualart.com/Artist/Mr--Brainwash/9B3FED6BB81E6B8E
██AAA
(node:17200) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
at Promise.then (C:temppuppeterr1node_modulespuppeteerlibFrameManager.js:1230:21)
at <anonymous>
-- ASYNC --
at Frame.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:144:27)
at Page.waitForNavigation (C:temppuppeterr1node_modulespuppeteerlibPage.js:599:49)
at Page.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:145:23)
at Object.<anonymous> (C:temppuppeterr1appserver2.js:127:30)
at step (C:temppuppeterr1appserver2.js:32:23)
at Object.next (C:temppuppeterr1appserver2.js:13:53)
at fulfilled (C:temppuppeterr1appserver2.js:4:58)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:17200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:17200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


Question:



What am I missing here ?

Why can't it reach the ██BBB ?



Complete code










share|improve this question




























    0















    Simplification :



    I have a website with links.

    After clicking on each link , it goes to a new page that I need to visit the links ( by clicking , not navigating).



    Visualization :



    enter image description here



    I've managed to do 99% percent of the job:



    (async () =>

    const browser = await puppeteer.launch(headless: false);
    const page = await browser.newPage();
    let url = "https://www.mutualart.com/Artists";
    console.log(`Fetching page data for : $url...`);
    await page.goto(url);
    await page.waitForSelector(".item.col-xs-3");
    let arrMainLinks: ElementHandle = await page.$$('.item.col-xs-3 > a'); //get the main links

    console.log(arrMainLinks.length); // 16


    for (let mainLink of arrMainLinks) //foreach main link let's click it

    let hrefValue =await (await mainLink.getProperty('href')).jsonValue();
    console.log("Clicking on " + hrefValue);
    await Promise.all([
    page.waitForNavigation(),
    mainLink.click(delay: 100)
    ]);

    // let's get the sub links
    let arrSubLinks: ElementHandle = await page.$$('.slide >a');

    //let's click on each sub click
    for (let sublink of arrSubLinks)

    console.log('██AAA');

    await Promise.all([
    page.waitForNavigation(),
    sublink.click(delay: 100)
    ]);
    console.log('██BBB');

    // await page.goBack()
    break; // for now ...

    break;



    await browser.close();
    )();


    So where is the problem ?



    It reaches the ██AAA

    But it never reaches ██BBB



    And I get an error :



     C:temppuppeterr1app>node server2.js
    Fetching page data for : https://www.mutualart.com/Artists...
    16
    Clicking on https://www.mutualart.com/Artist/Mr--Brainwash/9B3FED6BB81E6B8E
    ██AAA
    (node:17200) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
    at Promise.then (C:temppuppeterr1node_modulespuppeteerlibFrameManager.js:1230:21)
    at <anonymous>
    -- ASYNC --
    at Frame.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:144:27)
    at Page.waitForNavigation (C:temppuppeterr1node_modulespuppeteerlibPage.js:599:49)
    at Page.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:145:23)
    at Object.<anonymous> (C:temppuppeterr1appserver2.js:127:30)
    at step (C:temppuppeterr1appserver2.js:32:23)
    at Object.next (C:temppuppeterr1appserver2.js:13:53)
    at fulfilled (C:temppuppeterr1appserver2.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    (node:17200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:17200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


    Question:



    What am I missing here ?

    Why can't it reach the ██BBB ?



    Complete code










    share|improve this question


























      0












      0








      0


      0






      Simplification :



      I have a website with links.

      After clicking on each link , it goes to a new page that I need to visit the links ( by clicking , not navigating).



      Visualization :



      enter image description here



      I've managed to do 99% percent of the job:



      (async () =>

      const browser = await puppeteer.launch(headless: false);
      const page = await browser.newPage();
      let url = "https://www.mutualart.com/Artists";
      console.log(`Fetching page data for : $url...`);
      await page.goto(url);
      await page.waitForSelector(".item.col-xs-3");
      let arrMainLinks: ElementHandle = await page.$$('.item.col-xs-3 > a'); //get the main links

      console.log(arrMainLinks.length); // 16


      for (let mainLink of arrMainLinks) //foreach main link let's click it

      let hrefValue =await (await mainLink.getProperty('href')).jsonValue();
      console.log("Clicking on " + hrefValue);
      await Promise.all([
      page.waitForNavigation(),
      mainLink.click(delay: 100)
      ]);

      // let's get the sub links
      let arrSubLinks: ElementHandle = await page.$$('.slide >a');

      //let's click on each sub click
      for (let sublink of arrSubLinks)

      console.log('██AAA');

      await Promise.all([
      page.waitForNavigation(),
      sublink.click(delay: 100)
      ]);
      console.log('██BBB');

      // await page.goBack()
      break; // for now ...

      break;



      await browser.close();
      )();


      So where is the problem ?



      It reaches the ██AAA

      But it never reaches ██BBB



      And I get an error :



       C:temppuppeterr1app>node server2.js
      Fetching page data for : https://www.mutualart.com/Artists...
      16
      Clicking on https://www.mutualart.com/Artist/Mr--Brainwash/9B3FED6BB81E6B8E
      ██AAA
      (node:17200) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
      at Promise.then (C:temppuppeterr1node_modulespuppeteerlibFrameManager.js:1230:21)
      at <anonymous>
      -- ASYNC --
      at Frame.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:144:27)
      at Page.waitForNavigation (C:temppuppeterr1node_modulespuppeteerlibPage.js:599:49)
      at Page.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:145:23)
      at Object.<anonymous> (C:temppuppeterr1appserver2.js:127:30)
      at step (C:temppuppeterr1appserver2.js:32:23)
      at Object.next (C:temppuppeterr1appserver2.js:13:53)
      at fulfilled (C:temppuppeterr1appserver2.js:4:58)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)
      (node:17200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
      (node:17200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


      Question:



      What am I missing here ?

      Why can't it reach the ██BBB ?



      Complete code










      share|improve this question
















      Simplification :



      I have a website with links.

      After clicking on each link , it goes to a new page that I need to visit the links ( by clicking , not navigating).



      Visualization :



      enter image description here



      I've managed to do 99% percent of the job:



      (async () =>

      const browser = await puppeteer.launch(headless: false);
      const page = await browser.newPage();
      let url = "https://www.mutualart.com/Artists";
      console.log(`Fetching page data for : $url...`);
      await page.goto(url);
      await page.waitForSelector(".item.col-xs-3");
      let arrMainLinks: ElementHandle = await page.$$('.item.col-xs-3 > a'); //get the main links

      console.log(arrMainLinks.length); // 16


      for (let mainLink of arrMainLinks) //foreach main link let's click it

      let hrefValue =await (await mainLink.getProperty('href')).jsonValue();
      console.log("Clicking on " + hrefValue);
      await Promise.all([
      page.waitForNavigation(),
      mainLink.click(delay: 100)
      ]);

      // let's get the sub links
      let arrSubLinks: ElementHandle = await page.$$('.slide >a');

      //let's click on each sub click
      for (let sublink of arrSubLinks)

      console.log('██AAA');

      await Promise.all([
      page.waitForNavigation(),
      sublink.click(delay: 100)
      ]);
      console.log('██BBB');

      // await page.goBack()
      break; // for now ...

      break;



      await browser.close();
      )();


      So where is the problem ?



      It reaches the ██AAA

      But it never reaches ██BBB



      And I get an error :



       C:temppuppeterr1app>node server2.js
      Fetching page data for : https://www.mutualart.com/Artists...
      16
      Clicking on https://www.mutualart.com/Artist/Mr--Brainwash/9B3FED6BB81E6B8E
      ██AAA
      (node:17200) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
      at Promise.then (C:temppuppeterr1node_modulespuppeteerlibFrameManager.js:1230:21)
      at <anonymous>
      -- ASYNC --
      at Frame.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:144:27)
      at Page.waitForNavigation (C:temppuppeterr1node_modulespuppeteerlibPage.js:599:49)
      at Page.<anonymous> (C:temppuppeterr1node_modulespuppeteerlibhelper.js:145:23)
      at Object.<anonymous> (C:temppuppeterr1appserver2.js:127:30)
      at step (C:temppuppeterr1appserver2.js:32:23)
      at Object.next (C:temppuppeterr1appserver2.js:13:53)
      at fulfilled (C:temppuppeterr1appserver2.js:4:58)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)
      (node:17200) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
      (node:17200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


      Question:



      What am I missing here ?

      Why can't it reach the ██BBB ?



      Complete code







      javascript google-chrome automation puppeteer






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 19:17







      Royi Namir

















      asked Nov 13 '18 at 18:48









      Royi NamirRoyi Namir

      75.1k98330590




      75.1k98330590






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Update:



          https://github.com/GoogleChrome/puppeteer/issues/3535



          Original Answer:



          Update , I've managed to solve it but not via the regular way that I wanted.



          It seems that there is a problem with ElementHandle. Which is why I've moved to pure DOM objects.



          I'm still interested with a more intuitive solution rather by dealing with ElementHandle :



          Anyway here is my solution :



          (async () =>

          const browser = await puppeteer.launch(headless: false);
          const page = await browser.newPage();
          let url = "https://www.mutualart.com/Artists";
          console.log(`Fetching page data for : $url...`);
          await page.goto(url);
          await page.waitForSelector(".item.col-xs-3");

          let arrMainLinks = await page.evaluate(() =>


          return Array.from(document.querySelectorAll('.item.col-xs-3 > a'));
          );
          console.log(arrMainLinks.length);
          for (let i = 0; i < arrMainLinks.length; i++) //get the main links



          await page.evaluate((a) =>



          return ([...document.querySelectorAll('.item.col-xs-3 > a')][a] as HTMLElement ).click();
          , i);
          await page.waitForNavigation();
          let arrSubLinks2 = await page.evaluate(() =>

          return Array.from(document.querySelectorAll('.slide>a'));
          );
          console.log(arrSubLinks2.length);
          for (let j = 0; j < arrSubLinks2.length; j++)

          console.log('███AAA');
          await page.evaluate((a) =>


          return ([...document.querySelectorAll('.slide>a')][a] as HTMLElement) .click();
          , j);

          await page.waitForNavigation();
          let ddd: ElementHandle = await page.$$('.artist-name');
          console.log(ddd.length);

          console.log('███BBB');
          await page.waitFor(2000);
          await page.goBack();
          console.log('███CCC');


          await page.waitFor(2000);
          await page.goBack();

          await browser.close();
          )();





          share|improve this answer




















          • 1





            @AJC24 ................

            – Royi Namir
            Nov 14 '18 at 10:19











          • Apologies for my deleted answer - what I suggested worked once but only once and so I wanted to go back and retry it to make it more robust. I just didn't have time to come back to it yet.

            – AJC24
            Nov 14 '18 at 14:59











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287662%2fusing-puppeteer-to-click-main-links-and-clicking-sub-links%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Update:



          https://github.com/GoogleChrome/puppeteer/issues/3535



          Original Answer:



          Update , I've managed to solve it but not via the regular way that I wanted.



          It seems that there is a problem with ElementHandle. Which is why I've moved to pure DOM objects.



          I'm still interested with a more intuitive solution rather by dealing with ElementHandle :



          Anyway here is my solution :



          (async () =>

          const browser = await puppeteer.launch(headless: false);
          const page = await browser.newPage();
          let url = "https://www.mutualart.com/Artists";
          console.log(`Fetching page data for : $url...`);
          await page.goto(url);
          await page.waitForSelector(".item.col-xs-3");

          let arrMainLinks = await page.evaluate(() =>


          return Array.from(document.querySelectorAll('.item.col-xs-3 > a'));
          );
          console.log(arrMainLinks.length);
          for (let i = 0; i < arrMainLinks.length; i++) //get the main links



          await page.evaluate((a) =>



          return ([...document.querySelectorAll('.item.col-xs-3 > a')][a] as HTMLElement ).click();
          , i);
          await page.waitForNavigation();
          let arrSubLinks2 = await page.evaluate(() =>

          return Array.from(document.querySelectorAll('.slide>a'));
          );
          console.log(arrSubLinks2.length);
          for (let j = 0; j < arrSubLinks2.length; j++)

          console.log('███AAA');
          await page.evaluate((a) =>


          return ([...document.querySelectorAll('.slide>a')][a] as HTMLElement) .click();
          , j);

          await page.waitForNavigation();
          let ddd: ElementHandle = await page.$$('.artist-name');
          console.log(ddd.length);

          console.log('███BBB');
          await page.waitFor(2000);
          await page.goBack();
          console.log('███CCC');


          await page.waitFor(2000);
          await page.goBack();

          await browser.close();
          )();





          share|improve this answer




















          • 1





            @AJC24 ................

            – Royi Namir
            Nov 14 '18 at 10:19











          • Apologies for my deleted answer - what I suggested worked once but only once and so I wanted to go back and retry it to make it more robust. I just didn't have time to come back to it yet.

            – AJC24
            Nov 14 '18 at 14:59
















          0














          Update:



          https://github.com/GoogleChrome/puppeteer/issues/3535



          Original Answer:



          Update , I've managed to solve it but not via the regular way that I wanted.



          It seems that there is a problem with ElementHandle. Which is why I've moved to pure DOM objects.



          I'm still interested with a more intuitive solution rather by dealing with ElementHandle :



          Anyway here is my solution :



          (async () =>

          const browser = await puppeteer.launch(headless: false);
          const page = await browser.newPage();
          let url = "https://www.mutualart.com/Artists";
          console.log(`Fetching page data for : $url...`);
          await page.goto(url);
          await page.waitForSelector(".item.col-xs-3");

          let arrMainLinks = await page.evaluate(() =>


          return Array.from(document.querySelectorAll('.item.col-xs-3 > a'));
          );
          console.log(arrMainLinks.length);
          for (let i = 0; i < arrMainLinks.length; i++) //get the main links



          await page.evaluate((a) =>



          return ([...document.querySelectorAll('.item.col-xs-3 > a')][a] as HTMLElement ).click();
          , i);
          await page.waitForNavigation();
          let arrSubLinks2 = await page.evaluate(() =>

          return Array.from(document.querySelectorAll('.slide>a'));
          );
          console.log(arrSubLinks2.length);
          for (let j = 0; j < arrSubLinks2.length; j++)

          console.log('███AAA');
          await page.evaluate((a) =>


          return ([...document.querySelectorAll('.slide>a')][a] as HTMLElement) .click();
          , j);

          await page.waitForNavigation();
          let ddd: ElementHandle = await page.$$('.artist-name');
          console.log(ddd.length);

          console.log('███BBB');
          await page.waitFor(2000);
          await page.goBack();
          console.log('███CCC');


          await page.waitFor(2000);
          await page.goBack();

          await browser.close();
          )();





          share|improve this answer




















          • 1





            @AJC24 ................

            – Royi Namir
            Nov 14 '18 at 10:19











          • Apologies for my deleted answer - what I suggested worked once but only once and so I wanted to go back and retry it to make it more robust. I just didn't have time to come back to it yet.

            – AJC24
            Nov 14 '18 at 14:59














          0












          0








          0







          Update:



          https://github.com/GoogleChrome/puppeteer/issues/3535



          Original Answer:



          Update , I've managed to solve it but not via the regular way that I wanted.



          It seems that there is a problem with ElementHandle. Which is why I've moved to pure DOM objects.



          I'm still interested with a more intuitive solution rather by dealing with ElementHandle :



          Anyway here is my solution :



          (async () =>

          const browser = await puppeteer.launch(headless: false);
          const page = await browser.newPage();
          let url = "https://www.mutualart.com/Artists";
          console.log(`Fetching page data for : $url...`);
          await page.goto(url);
          await page.waitForSelector(".item.col-xs-3");

          let arrMainLinks = await page.evaluate(() =>


          return Array.from(document.querySelectorAll('.item.col-xs-3 > a'));
          );
          console.log(arrMainLinks.length);
          for (let i = 0; i < arrMainLinks.length; i++) //get the main links



          await page.evaluate((a) =>



          return ([...document.querySelectorAll('.item.col-xs-3 > a')][a] as HTMLElement ).click();
          , i);
          await page.waitForNavigation();
          let arrSubLinks2 = await page.evaluate(() =>

          return Array.from(document.querySelectorAll('.slide>a'));
          );
          console.log(arrSubLinks2.length);
          for (let j = 0; j < arrSubLinks2.length; j++)

          console.log('███AAA');
          await page.evaluate((a) =>


          return ([...document.querySelectorAll('.slide>a')][a] as HTMLElement) .click();
          , j);

          await page.waitForNavigation();
          let ddd: ElementHandle = await page.$$('.artist-name');
          console.log(ddd.length);

          console.log('███BBB');
          await page.waitFor(2000);
          await page.goBack();
          console.log('███CCC');


          await page.waitFor(2000);
          await page.goBack();

          await browser.close();
          )();





          share|improve this answer















          Update:



          https://github.com/GoogleChrome/puppeteer/issues/3535



          Original Answer:



          Update , I've managed to solve it but not via the regular way that I wanted.



          It seems that there is a problem with ElementHandle. Which is why I've moved to pure DOM objects.



          I'm still interested with a more intuitive solution rather by dealing with ElementHandle :



          Anyway here is my solution :



          (async () =>

          const browser = await puppeteer.launch(headless: false);
          const page = await browser.newPage();
          let url = "https://www.mutualart.com/Artists";
          console.log(`Fetching page data for : $url...`);
          await page.goto(url);
          await page.waitForSelector(".item.col-xs-3");

          let arrMainLinks = await page.evaluate(() =>


          return Array.from(document.querySelectorAll('.item.col-xs-3 > a'));
          );
          console.log(arrMainLinks.length);
          for (let i = 0; i < arrMainLinks.length; i++) //get the main links



          await page.evaluate((a) =>



          return ([...document.querySelectorAll('.item.col-xs-3 > a')][a] as HTMLElement ).click();
          , i);
          await page.waitForNavigation();
          let arrSubLinks2 = await page.evaluate(() =>

          return Array.from(document.querySelectorAll('.slide>a'));
          );
          console.log(arrSubLinks2.length);
          for (let j = 0; j < arrSubLinks2.length; j++)

          console.log('███AAA');
          await page.evaluate((a) =>


          return ([...document.querySelectorAll('.slide>a')][a] as HTMLElement) .click();
          , j);

          await page.waitForNavigation();
          let ddd: ElementHandle = await page.$$('.artist-name');
          console.log(ddd.length);

          console.log('███BBB');
          await page.waitFor(2000);
          await page.goBack();
          console.log('███CCC');


          await page.waitFor(2000);
          await page.goBack();

          await browser.close();
          )();






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 8:50

























          answered Nov 14 '18 at 10:18









          Royi NamirRoyi Namir

          75.1k98330590




          75.1k98330590







          • 1





            @AJC24 ................

            – Royi Namir
            Nov 14 '18 at 10:19











          • Apologies for my deleted answer - what I suggested worked once but only once and so I wanted to go back and retry it to make it more robust. I just didn't have time to come back to it yet.

            – AJC24
            Nov 14 '18 at 14:59













          • 1





            @AJC24 ................

            – Royi Namir
            Nov 14 '18 at 10:19











          • Apologies for my deleted answer - what I suggested worked once but only once and so I wanted to go back and retry it to make it more robust. I just didn't have time to come back to it yet.

            – AJC24
            Nov 14 '18 at 14:59








          1




          1





          @AJC24 ................

          – Royi Namir
          Nov 14 '18 at 10:19





          @AJC24 ................

          – Royi Namir
          Nov 14 '18 at 10:19













          Apologies for my deleted answer - what I suggested worked once but only once and so I wanted to go back and retry it to make it more robust. I just didn't have time to come back to it yet.

          – AJC24
          Nov 14 '18 at 14:59






          Apologies for my deleted answer - what I suggested worked once but only once and so I wanted to go back and retry it to make it more robust. I just didn't have time to come back to it yet.

          – AJC24
          Nov 14 '18 at 14:59


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287662%2fusing-puppeteer-to-click-main-links-and-clicking-sub-links%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto