Xetera / ghost-cursor

🖱️ Generate human-like mouse movements with puppeteer or on any 2D plane
MIT License
1.09k stars 118 forks source link

How to use MouseHelper #12

Closed fishing4chicken closed 3 years ago

fishing4chicken commented 3 years ago

I see the latest version includes installMouseHelper, is this supposed to work like the video in the README, where you can see a small grey circle where the cursor moves?

If so, could you help explain how to set it up? I am a little new to the node.js game and this was my best guess:

const { installMouseHelper } = require('ghost-cursor'); await installMouseHelper(page)

But I don't see the same grey circle when I use Puppeteer in head-full mode.

Really appreciate the Ghost-cursor team! Ghost-cursor is awesome

Niek commented 3 years ago

I really need to update the documentation (PRs are welcome ;))

This is a short sample code:

const { createCursor, getRandomPagePoint, installMouseHelper } = require('ghost-cursor');

// launch puppeteer first, initialize page, etc. then:

const cursor = createCursor(page, await getRandomPagePoint(page));
await installMouseHelper(page);

await page.goto('https://old.reddit.com/');
await cursor.click('.footer a', { waitForMouse: 10000, waitForSelector: 1000, paddingPercentage: 20 });
fishing4chicken commented 3 years ago

Thanks Niek!

The problem I had was that I my"installMouseHelper(page)" was after "page.goto()" , instead of before

Works perfectly now!