In Puppeteer, you can chain multiple actions like click and type using the page
object and the keyboard
and mouse
modules. Here's an example of how you can chain a click action with a type action:
npm install puppeteer
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.example.com');
await page.click('#myElementId');
await page.keyboard.type('Hello, World!');
await browser.close();
})();
In this example, the script will first navigate to https://www.example.com
, then click on an element with an id of myElementId
, and finally type Hello, World!
using the keyboard module.
node yourscript.js
That's it! You have successfully chained multiple actions (click and type) in Puppeteer.