title: Puppeteer - Cannot read property 'click' of undefined
body: <p>When i set headless: true (without open browser) in Puppeteer i have error Error: </p>
  
  <blockquote>
    <p>Evaluation failed: TypeError: Cannot read property 'click' of
    undefined at <strong>puppeteer_evaluation_script</strong>:3:115</p>
  </blockquote>
  
  <p>I add that if is headless: false (with open browser) the script works correctly...
  From my observations, it appears that the error occurs while performing this function</p>
  
  <pre><code>await page.evaluate( () =&gt;
      {
      Array.from( document.querySelectorAll( '.N3ewq' ) ).filter( element =&gt; element.textContent == 'Switch' )[0].click();
      });
  </code></pre>
  
  <p>How can I fix it? Thanks for all suggestions</p>