Using this function to type human like is partially working: the text is typed, but there's some random characters missing.
const slowType = async (elementHandle, message) => {
const minDelay = 60;
const maxDelay = 150;
await elementHandle.focus();
for (const chr of message) {
console.log(chr);
await elementHandle.type(chr);
await sleep(Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay);
}
};
// The use of the function:
message = 'lorem ipsum doloris';
const element = await page.$('textarea[id="xxx"]');
await slowType(element, messages);
all characters are printed from the console.log()
, but some are missing in the final textarea
. There's no errors. Tried many things like page.type('selector', chr)
.
How can I fix this?