在 Puppeteer 中可视化鼠标位置
Visualizing the mouse position in Puppeteer
我有下面的代码来移动鼠标
await page.mouse.move(500, 600);
但是当它转到页面时,我没有看到我的光标在移动。 Puppeteer 是否出于某种原因隐藏了鼠标光标,因此我看不到它?
Puppeteer 无法控制操作系统的鼠标——它只能控制浏览器,它提供了以编程方式生成鼠标事件的能力,而无需实际移动操作系统的鼠标,如果您考虑一下,不受欢迎。
我假设通过问这个问题,你的最终目标是实际看到由 Puppeteer 控制的鼠标位置。这似乎还没有在 Stack Overflow 上被问到,但是 Puppeteer issue #4378 has code (install-mouse-helper.js
) to render an HTML element on top of the mouse's logical location in the top-level frame for debugging purposes. This is done entirely in the browser, adding CSS and an element that updates on various mouse events. There's nothing Puppeteer-specific about it other than page.evaluateOnNewDocument
以确保代码在导航后运行。
我有下面的代码来移动鼠标
await page.mouse.move(500, 600);
但是当它转到页面时,我没有看到我的光标在移动。 Puppeteer 是否出于某种原因隐藏了鼠标光标,因此我看不到它?
Puppeteer 无法控制操作系统的鼠标——它只能控制浏览器,它提供了以编程方式生成鼠标事件的能力,而无需实际移动操作系统的鼠标,如果您考虑一下,不受欢迎。
我假设通过问这个问题,你的最终目标是实际看到由 Puppeteer 控制的鼠标位置。这似乎还没有在 Stack Overflow 上被问到,但是 Puppeteer issue #4378 has code (install-mouse-helper.js
) to render an HTML element on top of the mouse's logical location in the top-level frame for debugging purposes. This is done entirely in the browser, adding CSS and an element that updates on various mouse events. There's nothing Puppeteer-specific about it other than page.evaluateOnNewDocument
以确保代码在导航后运行。