title: Return window object using puppeteer
body: <p>I'm trying to return the whole windows object from a page, and then traversing the object outside of puppeteer.</p>
  
  <p>I'm trying to access the data in Highcharts property, for which I need to access the window object. The normal javascript code being something like <code>window.Highcharts.charts[0].series[0].data</code>.</p>
  
  <p>I thought the easiest way would be to use puppeteer to access the site, and just send me back the windows object, which I could then use outside of puppeteer like any other JS object.</p>
  
  <p>After reading the documentation, I'm finding it difficult to return the object as it would appear just putting 'window' into the chrome console. I'm not sure what I'm missing?</p>
  
  <p>I've read through the documentation, and the following two methods seem like they should work?</p>
  
  <pre><code>(async () =&gt; {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.goto('https://www.example.com', {waitUntil: 'networkidle2'});
  
      // METHOD 1
      // Create a Map object
      await page.evaluate(() =&gt; window.map = new Map());
      // Get a handle to the Map object prototype
      const mapPrototype = await page.evaluateHandle(() =&gt; Map.prototype);
      // Query all map instances into an array
      const mapInstances = await page.queryObjects(mapPrototype);
  
      console.log(mapInstances);
  
      await mapInstances.dispose();
      await mapPrototype.dispose();
  
      // METHOD 2
      const handle = await page.evaluateHandle(() =&gt; ({window, document}));
      const properties = await handle.getProperties();
      const windowHandle = properties.get('window');
      const documentHandle = properties.get('document');
      var result = await page.evaluate(win =&gt; win, windowHandle);
  
      console.log(result)
  
      await handle.dispose();
  
  
  
      await browser.close();
  })();
  </code></pre>
  
  <p>However, it only returns the following in the console, and not the simple object I would like;</p>
  
  <p><a href="https://i.stack.imgur.com/D3ymx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D3ymx.png" alt="enter image description here"></a></p>
  
  <p>Not sure if I'm going about this the right way, so any help/advice is much appreciated.</p>