title: Xpath: Working in Devtools but returns empty object with document.evaluate()
body: <p>The following command works as expected in Devtools console (for example, here - <a href="https://news.ycombinator.com/" rel="nofollow noreferrer">https://news.ycombinator.com/</a>)</p>
  <p><code>$x('//a[@class=&quot;storylink&quot;]')</code> (Edge browser)</p>
  <p>But the following code:</p>
  <pre><code>            const page = await browser.newPage();
              await page.goto(&quot;https://news.ycombinator.com/&quot;);
              let urls = await page.evaluate(() =&gt; {
                  var item = document.evaluate(
                      '//a[@class=&quot;storylink&quot;]',
                      document,
                      null,
                      XPathResult.FIRST_ORDERED_NODE_TYPE,
                      null
                  ).singleNodeValue;
                  return item
              })
              browser.close(); 
  </code></pre>
  <p>returns an empty object: <code>{}</code>. The same is happening in every other website.
  Why is that happening?</p>