Javascript code to Puppeteer for(…of…)

  javascript, puppeteer, selector

I have the following javascript code, which I want to implement in puppeteer, to do something like:

   await page.click(myDivs[0])
 const myDivs = [];
     for (const div of page.querySelectorAll("div.b-swatch-value-wrapper")) {
        if (div.querySelector("span.b-swatch-value--orderable") !== null) {
          myDivs.push(div.b-swatch-value-wrapper);
            }
        }

Like this its obviously not working, but how do I do this? Thank you in advance 🙂

Source: Ask Javascript Questions

LEAVE A COMMENT