Xetera / ghost-cursor

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

Falling back to JS scroll method TypeError: page._client.send is not a function #67

Closed firmart closed 2 years ago

firmart commented 2 years ago

Since puppeteer 13.6.0, the correct way to create a CDP session client is

const client = await page.target().createCDPSession();

Related: #61

See

Niek commented 2 years ago

Are you using the latest version? We have this fix in place to prevent this issue: https://github.com/Xetera/ghost-cursor/blob/7327dfa3215e6f2a9391af650ff2221c2e4dfe80/src/spoof.ts#L85

If you still experience this on the latest version, please provide a reproducible script.

firmart commented 2 years ago

I have seen this line but didn't update to the latest. Now, updated to the latest version (i.e. from 1.1.8 to 1.1.15), I got another error:

TypeError: elem.remoteObject is not a function
    at Object.<anonymous> (/node_modules/ghost-cursor/lib/spoof.js:458:61)
    at step (/node_modules/ghost-cursor/lib/spoof.js:44:23)
    at Object.next (/node_modules/ghost-cursor/lib/spoof.js:25:53)
    at fulfilled (/node_modules/ghost-cursor/lib/spoof.js:16:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

BTW, any reason to access internal field like _client instead of the aforementioned const client = await page.target().createCDPSession() ?

Niek commented 2 years ago

Can you share the snippet where you get the remoteObject error @firmart?

The reason we don't use createCDPSession() is that it opens an additional CDP session instead of using the existing session, i.e. extra overhead.

Niek commented 2 years ago

Closing for now - if you get the remoteObject error, please open a new issue @firmart