Categories
JavaScript Answers

How to fill an input field using Puppeteer and JavaScript?

Spread the love

Sometimes, we want to fill an input field using Puppeteer and JavaScript.

In this article, we’ll look at how to fill an input field using Puppeteer and JavaScript.

How to fill an input field using Puppeteer and JavaScript?

To fill an input field using Puppeteer and JavaScript, we can use the page.keyword.type method.

For instance, we write

await page.focus("#email");
await page.keyboard.type("test");

to focus on the input with ID email with

await page.focus("#email");

Then we type in the input we focused on with

await page.keyboard.type("test");

Conclusion

To fill an input field using Puppeteer and JavaScript, we can use the page.keyword.type method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *