title: How to get a collection of elements with playwright?
body: <p>How to get all images on the page with playwright?
  I'm able to get only one (<code>ElementHandle</code>) with following code, but not a collection.</p>
  
  <pre><code>const { chromium } = require("playwright");
  
  class Parser {
    async parse(url) {
      const browser = await chromium.launch();
      const page = await browser.newPage();
      await page.goto(url);
      await page.waitFor("img");
      // TODO: get somehow collection of elements
      return await page.$("img");
    }
  }
  
  module.exports = Parser;
  </code></pre>
  
  <p>Somewhere in another module far far away:</p>
  
  <pre><code>const Parser = require("./path/to/dir/Parser.js");
  const parser = new Parser();
  
  parser
      .parse(body.url)
      .then(elemHandle =&gt; {
        // here I get only one ElementHandle object, but suppose to get an array or collection
      })
      .catch(err =&gt; {
        throw new Error(err);
      });
  </code></pre>
  
  <p>Node v.12.16.1</p>