简体   繁体   中英

How to get mouse position with puppeteer

I'am trying to open a page with puppeteer, and in that page I want to move the mouse in that page to the position of the current mouse that iam using, but i cant find anything, so i was wondering if it was possible

You can get the coordinates of the mouse by this way:

 page.evaluate(() => { document.onmousemove = function(e){ mouseX = e.offsetX; mouseY = e.offsetY; console.log(mouseX, mouseY); } })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM