mouse-helper
Version:
A tool to show mouse position and status for screenshots in automation test such as Puppeteer or Playwright
66 lines (51 loc) • 1.5 kB
Markdown
> A tool to show mouse position and status for screenshots in automation test such as [Puppeteer](https://github.com/puppeteer/puppeteer) or [Playwright](https://github.com/microsoft/playwright)
```sh
npm i mouse-helper
```
[](https://cenfun.github.io/mouse-helper/)
screenshot mouse move(20, 50)

screenshot mouse down

screenshot mouse none (mouse never moved)

## Usage
```js
require("mouse-helper")();
```
```html
<script src="dist/mouse-helper.js"></script>
<script>
window['mouse-helper']();
</script>
```
see [/public/index.html](/public/index.html)
```js
const { chromium } = require('playwright');
const browser = await chromium.launch();
const context = await browser.newContext();
await context.addInitScript({
path: './node_modules/mouse-helper/dist/mouse-helper.js'
});
const page = await context.newPage();
await page.goto("your page url");
await page.evaluate(() => {
window['mouse-helper']();
});
await page.mouse.move(20, 50);
await page.screenshot({
path: "your screenshot path"
});
await page.mouse.down();
await page.screenshot({
path: "your screenshot path"
});
await page.mouse.up();
```
see [/scripts/test.js](/scripts/test.js)