I'm trying to click the 'Show more' button, on a google search for a recipe, multiple times using puppeteer. I have it working in a for loop like this,
for (let i = 0; i <= numberOfClicks; i++) {
    await page.click('div[aria-label="Show more"]')
    await page.waitForTimeout(800)
  }
However this adds 800ms for every click, which I would really like to avoid to save time on the call I'm making.
I've tried various different ways of doing this and feel something like this,
for (let i = 0; i <= numberOfClicks; i++) {
    await page.waitForFunction(
      `document.querySelectorAll("g-inner-card a").length > ${i * 9}`
    )
    await page.click('div[aria-label="Show more"]')
  }
should do what I need, as google starts with 3 recipes and opens 9 more every time you click 'Show more', however, so far I can only get it to click once and then hangs with this method.
Any help would be really appreciated, thanks.
 
    