reaz1995 / ghost-cursor-playwright

Modification of actual ghost-cursor for puppeteer, with more functionality and rewrited to work well with playwight.
52 stars 16 forks source link

Mouse movements are immediate #5

Closed tinbka closed 1 year ago

tinbka commented 1 year ago

Hey there @reaz1995, thanks for the development effort first of all.

Isn't the cursor on the Page supposed to move with a relatively slow speed with a curve path, and slow down before it reaches the target, as a human would do? When I execute page.cursor.actions.move(locatorName) I don't see a trajectory at all, I just see the cursor immediately teleporting to the selected element as if my screen is a touch device rather than a desktop with a mouse and a human just tapped it in the right place with a finger.

Do I need to set an additional option to move or something?

reaz1995 commented 1 year ago

You didn't provide code sample so:

  1. Run demo attached to package and check if it does working correctly.
  2. Read README When cursor jumping directly to provided locator it mean it's in error state, probably something wrong with provided locator or your usage of this package. Make sure that everything is correct with provided locator.
tinbka commented 1 year ago

It started working as expected in a few tries. I'm not sure what was actually a culprit. I ended up wrapping it in a Page fn like this:

  click: async function(locString, ...locTimeout) {
    const loc = this.locator(locString, ...locTimeout);
    await this.cursor.actions.click({ target: await loc.boundingBox(), waitBeforeClick: [100, 1000] });
    return loc;
  },

passing it boundingBox as a target because this way it would allow using sophisticated playwright locators like 'internal:text="sign in"i'

reaz1995 commented 1 year ago

As i mentoned, when it moves directly to target it's in error mode, make sure you correctly handled promises. This part doesn't look correctly for me { target: await loc.boundingBox(). might be better to handle it before passing as arg.