How can I use $x() to use xpath expression inside a page.evaluate() ?
$x()
As far as page is not in the same context, I tried $x()
page
If you insist on using page.$x(), you can simply pass the result to page.evaluate():
const example = await page.evaluate(element => { return element.textContent; }, (await page.$x('//*[@id="result"]'))[0]);