该表单存在于页面中,我确信。
const form = await page.$('#my-form');
await form.evaluate(form => form.submit());
我收到此错误:
TypeError: form.evaluate is not a function
最佳答案
编辑 2019:正如凯尔所说,最新的 puppeteer 操纵者有 .evaluate method on elementHandle .毕竟已经两年了。
const tweetHandle = await page.$('.tweet .retweets');
expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10');
你可以试试这个方法
await page.evaluate(() => {
const element = document.querySelector("#my-form")
element.submit()
});
ElementHandle
没有 .evaluate
功能属性。检查 docs .
关于puppeteer 表单提交 : evaluate is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46949910/