await page.evaluate(num => num, 42);
await page.evaluate(array => array.length, [1, 2, 3]);
await page.evaluate(object => object.foo, { foo: 'bar' });
const button = await page.$('button');
await page.evaluate(button => button.textContent, button);
await button.evaluate((button, from) => button.textContent.substring(from), 5);
const button1 = await page.$('.button1');
const button2 = await page.$('.button2');
await page.evaluate(
o => o.button1.textContent + o.button2.textContent,
{ button1, button2 });
await page.evaluate(
({ button1, button2 }) => button1.textContent + button2.textContent,
{ button1, button2 });
await page.evaluate(
([b1, b2]) => b1.textContent + b2.textContent,
[button1, button2]);
await page.evaluate(
x => x.button1.textContent + x.list[0].textContent + String(x.foo),
{ button1, list: [button2], foo: null });