I'm trying to run this code:
var aaa = await page.$$eval(selector, list => (list, value) =>
{
return resolve(list.find(element => element.textContent === value));
}
,value);
But I received an error.
Therefore, I tried to print the items in "list" (because I assumed that the problem is there), I tried this code:
var aaa = await page.$$eval(selector, list => list);
And I received that "aaa" is empty.
Any idea what may be the problem?
Just try to map your array to more serializable one.
For example:
You are attempting to return DOM elements from
page.$$eval()
, which will returnundefined
because DOM elements are not serializable.Try using
page.$$()
instead if you would like to return anElementHandle
array.Take a look at the Puppeteer Documentation for
page.$$eval()
below: