I try to figure out how to send Down in puppeteer, I tried with the int code 40
or Down
string, but none works.
Is there a proper way ? Can't figure it out after reading ~/node_modules/puppeteer/lib/Input.js
const elementHandle = await page.$('selector');
await elementHandle.type('something');
await page.keyboard.press(40); // fail
You need to use 'ArrowDown'
.
The keyboard.press
functions wants a string as name of the key.
https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#keyboardpresskey-options
So the line to press the down arrow would be:
await page.keyboard.press('ArrowDown');
Here is the list of available keys: https://github.com/puppeteer/puppeteer/blob/main/src/common/USKeyboardLayout.ts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With