ghost-cursor icon indicating copy to clipboard operation
ghost-cursor copied to clipboard

Add clickCount functionality -> Update spoof.ts

Open spatterIight opened this issue 1 year ago • 0 comments

This commit adds a clickCount parameter to the click() function, similar to puppeteer's

The use case for me is highlighting all the text in an input field before typing into it, such that typing overwrites any value already present

I do not believe the waitForClick parameter would function as expected when specified simultaneously with this new clickCount parameter, so I suspect some changes may be needed before merged.

One thought I had was simply using a for loop to perform up() and down() repeatedly, preserving the delay. However it doesn't seem to work, I am not sure why.

await page.mouse.down()
if (options?.waitForClick !== undefined) { await delay(options.waitForClick) }
if (options?.clickCount !== undefined) {
  for(var i = 0; i < options.clickCount-1; i++) {
    await page.mouse.down()
    if (options?.waitForClick !== undefined) { await delay(options.waitForClick) }
    await page.mouse.up()
  }
await page.mouse.up()

awesome project btw!

spatterIight avatar Nov 20 '22 04:11 spatterIight