Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

puppeteer form submit: evaluate is not a function

Tags:

puppeteer

the form exists in the page and i am sure.

const form = await page.$('#my-form');
await form.evaluate(form => form.submit());

I get this error:

TypeError: form.evaluate is not a function
like image 551
redochka Avatar asked Oct 29 '22 00:10

redochka


1 Answers

EDIT 2019: As mentioned by Kyle, the latest puppeteer have .evaluate method on elementHandle. It's been two years after all.

const tweetHandle = await page.$('.tweet .retweets');
expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10');

You can try it this way,

await page.evaluate(() => {
 const element = document.querySelector("#my-form")
 element.submit()
});

ElementHandle does not have a .evaluate function property. Check the docs.

like image 88
Md. Abu Taher Avatar answered Dec 03 '22 11:12

Md. Abu Taher