Closed PramodKumarYadav closed 2 months ago
The code you provided is unfortunately not complete - would it be possible to share a minimal reproduction which we can clone and run locally? Ideally with expected and actual outcome. Thanks for your understanding!
Will setup a working example today and share. Thanks for your prompt response @mxschmitt . Appreciate it.
@mxschmitt: Here are requested details:
playwright.config.ts
file here: snapshotPathTemplate:
.screenshots/{testFilePath}/{arg}{ext},
npx playwright test --grep=visual-test --project=chromium
Thank you for your loom, that was helpful! I tried to run your sample-field test locally and for me it passes headless and headed via the VSCode extension with the lowest maxDiffPixels: of 74
. I tried doing it via VSCode and via the command line. When looking at your code, I see that you specify the ratio and the pixels. In this case, we take the minimum when both is specified, that might end up in some confusion on your end: https://github.com/microsoft/playwright/blob/f374f8db38c8ab1fe9674a1839bd9fdbc5023842/packages/playwright-core/src/utils/comparators.ts#L85-L86
Closing as per above. If you still encounter problems, please file a new issue by filling in the "Bug Report" template and link to this one.
Hi @PramodKumarYadav
- Expected an image 537px by 47px, received 529px by 47px.
This error getting because expected and actual image size not matching
sizesMismatchError
if we bypass pixelsMismatchError
by passing maxDiffPixels
or maxDiffPixelRatio
, But sizesMismatchError
will return the error
https://github.com/microsoft/playwright/blob/f374f8db38c8ab1fe9674a1839bd9fdbc5023842/packages/playwright-core/src/utils/comparators.ts#L91-L93
Version
1.45.0
Steps to reproduce
NOTE: I have the setup working on a customer project so I dont have a generically accessible code to reproduce this at the moment but am sure the same issue can be verified if we run tests in a headed (VSCode plugin -> Settings -> Show Browser) or headless mode on any UI application. If this is not the case, do let me know and I will try to create a reproducible example and share.
For now, here are the steps and issue.
npx playwright test --grep=user-mgmt-search --project=ux-tests
. With this the below test passes:- Expected an image 537px by 47px, received 529px by 47px. 98 pixels (ratio 0.01 of all image pixels) are different.
Expected behavior
Since the ratios are higher than the differences, I expect the tests to pass.
Actual behavior
Even if I make these ratios much higher - even to their max limit, the test still fails with below error.
- Expected an image 537px by 47px, received 529px by 47px.
Additional context
Due to this reason I am not able to use the visual comparison tests for isolated fields in our tests. Kindly let me know if I am doing something wrong here.
Environment