I'm trying to use Pupppeteer in Electron to do some automation. I tested the following code with simple command node test.js without any errors:
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.facebook.com/');
await page.waitFor(2000);
await page.click('button[type="submit"]');
await page.waitFor(2000);
await page.screenshot({ path: 'example.png' });
await browser.close();
})();
but when I ran the exact same code in in Electron I get the following error which points out there an error with await page.click('button[type="submit"]');
Uncaught (in promise) Error: Passed function is not well-serializable!
at ExecutionContext._evaluateInternal (ExecutionContext.ts:247)
at ExecutionContext.evaluateHandle (ExecutionContext.ts:191)
at ElementHandle.evaluateHandle (JSHandle.ts:183)
at Object.internalHandler.queryOne (QueryHandler.ts:68)
at ElementHandle.$ (JSHandle.ts:778)
at DOMWorld.$ (DOMWorld.ts:171)
at async DOMWorld.click (DOMWorld.ts:434)
at async file:/Users/usr/Desktop/aa/renderer.js:17
how can I fix it??