-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Mouse helper (tracking mouse position, clicks, drag & drops, selections) #1374
Comments
This will be addressed by #3526 (review) |
Yes, in our test cases a lot of the time it's difficult to know at exactly what line playwright failed. Having visual confirmation; most importantly in the video if & where mouse clicks were performed will for some issues certainly help us to identify them. In cypress when you hover over an action in the action bar & the action is a click, you see the click on the screenshot for that moment, which is quite helpful. |
This should be now addressed with a much more advanced ui - please check out the new playwright inspector: https://playwright.dev/docs/inspector/ I'll close this bug now. We continue working on making inspector UI nicer and more helpful, so if you have any issues or suggestions for it, please file separate issues! |
@aslushnikov Maybe I am missing something, but how does this work if I execute a I.e. I want this to use this in CI when a test case fails, I take a screenshot, and see where it failed. Without having to re-run with the inspector. |
yeah, that would also be our preferred usage. We want to run it during our CI runs. We found out that +- 40% of the work is building the tests; but +-60% of the time we spend on hardening them when 1 in 20 runs a command fails because for that run it behaves a bit different because the CPU was slower or whatever. It's there that we would like to gain time. |
@thernstig @LanderBeeuwsaert good points! Re-opening then |
@aslushnikov great :) No idea of how you achieved this with the inspector, but hopefully you can re-use some of that code for also this scenario we described i.e. in CI. |
Interestingly, there is already such a mouse helper available separately, originally made for Puppeteer it seems: https://gist.github.com/aslushnikov/94108a4094532c7752135c42e12a00eb (Doesn't compile on my side because However, of course it would be really nice and helpful, to have such a feature integrated in Playwright, including the possibility to activate it as needed via API (e.g. @thernstig The PW inspector does highlight mouse positions upon actions but no mouse movements, AFAIK. |
@klhex that was linked from the original post, and if you look closely you will notice that it is @aslushnikov who has written it 😛 |
@thernstig Right, I didn't notice that it was already linked in the first comment. Guess it's time to call it a day. ;) (However, I did notice that it was written by aslushnikov. :) |
Any news on this? Would love to see this feature. The maybe related pull request (#3526 (review)) is still closed. Would like to see this feature to automatize generation of small screen videos for tutorials. Any other ideas and hints on how to do this? |
Linking to related issues #6737 and #5816. These are critical for my team for using Playwright to test our WebGL app, https://spatial.io |
This would be especially useful for CI/CD environments! In my case, I am running all my tests in the background (CI/CD) in headed mode with screen recording enabled by default, incl. automatic upload of the recordings to S3. With a mouse helper that I would also activate by default for all my tests, I would be able to detect issues related to flakiness, most prominent example being that PW confirms it has successfully clicked on "Next" button but nevertheless the application is not navigating to the next page, as it normally should. If I run the test again, usually the issue does not reappear (flake) and therefore I cannot use the PW trace viewer to analyze the issue further. Currently, the only alternative would be to enable the trace viewer by default for all test executions but this would be overkill since such flake issues only occur rarely and having it always activated would slow down the tests quite a bit... |
+1, that would be so helpful! |
+1 |
Seems like using Tracing with Action Snapshot turned on does the job: |
You can simulate a mouse with mouse-helper npm i mouse-helper Usage 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(); |
I think trace (and its viewer) doesn't cover all dev needs. Looks like some helper need to draw what is mouse/keyboard doing as part of the video object. Second vector is a Chrome extension to highlight mouse events. |
Is there a way to add the red circle (tracer) to the videos? it does it for the Actions but when a video is created it loses it and it is hard to follow. |
It would be nice to natively have support for a mouse helper. So if running in headful mode, or taking a screenshot, or video recording, one would see where the mouse is, text selections, drag & drops, and where it clicks during a failure.
@aslushnikov already had one in Puppeteer but it required installing it, but maybe it could be default-installed on the browserContext or page instead if wanted, or even for the browser. Having it out of the box would improve usability for all users. Especially during debugging.
puppeteer/puppeteer#4378 (comment)
The text was updated successfully, but these errors were encountered: