I am trying to enter some text in a textarea field using Puppeteer.
My approach is to copy the text to the clipboard, then click on the textarea and try to paste it in. However, the text is not added to the input field.
Things I've tried:
Using page.type takes a long time because the text is a few thousand characters. I would rather avoid this.
Using page.$eval("#textarea", (el, in) => el.value = in, text) does not work because the site is an SPA.
await clipboardy.writeSync(text);
await page.click("#textarea")
await page.waitFor(500);
await page.keyboard.down('Control');
await page.keyboard.down('Shift');
await page.keyboard.press('KeyV');
await page.keyboard.up('Control');
await page.keyboard.up('Shift');
// does not paste
// also tried, clipboardy.readSync();
// does not paste either
The expected result is to enter the text in the SPA textarea.
To answer my own question, the above approach with copy/paste works fine.
The problem was that my text string was empty. :[
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