Reputation: 1759
Everytime I pass an xpath to my function it returns string is not a valid XPath expression
. Why is that?
const searchSelector = '//*table/tbody/tr/td[1]';
const result = await page.evaluate(element => {
return element.textContent;
}, await page.$x(searchSelector));
Upvotes: 0
Views: 815
Reputation: 56162
Because it is not a valid XPath, consider this XPath:
//table/tbody/tr/td[1]
or if you need to rely on class
name:
//table[@class = 'classname']/tbody/tr/td[1]
Upvotes: 2