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.
- Run tests only for a particular input field without giving any options in headless mode.
- Command I use to run:
npx playwright test --grep=user-mgmt-search --project=ux-tests. With this the below test passes:
test("user-mgmt-search", async ({ page, userManagementPage, }) => {
await userManagementPage.goTo();
const searchUserInput = page.getByPlaceholder("Start typing to search");
await expect(searchUserInput).toHaveScreenshot({});
});
2 passed (9.2s)
::notice title=🎭 Playwright Run Summary:: 2 passed (9.2s)
- Now run the same test in headed mode by going to VSCode plugin -> Settings -> Show Browser option.
- This time, run test from clicking the button from UI and verify results.
- Test throws an error
- Expected an image 537px by 47px, received 529px by 47px. 98 pixels (ratio 0.01 of all image pixels) are different.
- Now go to test and change pixel thresholds above the ones shown above. i.e. more than 98 pixels or more than 0.01. I will set both for this particular test.
test("user-mgmt-search", async ({ page, userManagementPage, }) => {
await userManagementPage.goTo();
const searchUserInput = page.getByPlaceholder("Start typing to search");
await expect(searchUserInput).toHaveScreenshot({
maxDiffPixels: 100, // maximum number of different pixels
maxDiffPixelRatio: 0.1, // maximum ratio of different pixels
threshold: 0.5 // color comparison threshold (0-1)
});
});
- Run test again from UI.
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
System:
OS: macOS 14.0
CPU: (8) arm64 Apple M2
Memory: 60.63 MB / 16.00 GB
Binaries:
Node: 21.7.1 - /opt/homebrew/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.8.1 - /opt/homebrew/bin/npm
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
@playwright/test: ^1.45.0 => 1.45.0
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
System: OS: macOS 14.0 CPU: (8) arm64 Apple M2 Memory: 60.63 MB / 16.00 GB Binaries: Node: 21.7.1 - /opt/homebrew/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 10.8.1 - /opt/homebrew/bin/npm Languages: Bash: 3.2.57 - /bin/bash npmPackages: @playwright/test: ^1.45.0 => 1.45.0