title: How to execute Node.js code in the browser context?
body: <p><strong>How do I execute client-side JS code within the <code>page.evaluate()</code> statement (not just browser JavaScript code, Node.js code)?</strong></p>
  
  <pre><code>const puppeteer = require('puppeteer');
  
  (async () =&gt; {
   const browser = await puppeteer.launch();
   const page = await browser.newPage();
    await page.goto('https://example.com');
    await page.screenshot({path: 'example.png'});
    await page.evaluate(() =&gt; {
      document.querySelector('button[type=submit]').click();
    });
    console.log('yes') 
    await browser.close();
  })();
  </code></pre>