playwright-java icon indicating copy to clipboard operation
playwright-java copied to clipboard

[Feature] Visual comparisons port to java library

Open kabhinav26 opened this issue 3 years ago • 16 comments

Playwright node.js already has "Visual comparisons" functionality which can be used for visual regression testing, we need the same in playwright java library as well.

image

kabhinav26 avatar Aug 30 '22 10:08 kabhinav26

I am totally ++++. It would be great to have it for all other languages.

NikkTod avatar Aug 31 '22 12:08 NikkTod

This is a part of playwright test runner in node.js world. The test runner manages the screenshot files and directories, generating names for them etc. We can expose the image matching functions but JUnit/TestNG don't have built in support for managing test artifacts and we don't have our own runner in Java. Do you think that having something like assertThat(page).hasScreenshot(path) would be sufficient?

yury-s avatar Aug 31 '22 15:08 yury-s

The issue here is that people programing on the other langusges are seeing the great features that are being added to the node js runner and we get envious. Would be nice to have a Playwright runner in all other supported langusges :)

As for the hasScreenshot(path) not sure how it would help, we need visual comparison feature.

NikkTod avatar Sep 02 '22 17:09 NikkTod

In our framework we are using listeners to capture screenshots and manage file names, so it would be good to have atleast the functionality already present in node.js version.

From documentation i see there are assertions involving pixel threshold and content.

await expect(page).toHaveScreenshot({ maxDiffPixels: 100 }); expect(await page.textContent('.hero__title')).toMatchSnapshot('hero.txt');

kabhinav26 avatar Sep 05 '22 04:09 kabhinav26

Selenium has ashot library which supports visual testing on below parameters:

comparison of screenshots of pages; comparing screenshots of pages + ignoring specified elements (dynamic content, etc.); comparison of screenshots of elements; breakpoints – you can compare screenshots of pages or elements with different widths. The default is 3 breakpoints – 1920px, 768px, 360px; auto-generation of expected screenshots; you can write tests as ordinary functional automation tests, there are no restrictions – this is important because sometimes it may be necessary to perform some complex actions before taking a screenshot.

kabhinav26 avatar Sep 05 '22 05:09 kabhinav26

@yury-s Could the following features be added? We would appreciate it if you could add them.

assertThat(page).hasScreenshot(path)

tsachi368 avatar Oct 31 '22 04:10 tsachi368

Hello @yury-s - assertThat(page).hasScreenshot(path) would be great feature to have, exposing the image matching functions is the important thing here.

Is there any timeline for that feature to be developed? :)

NikkTod avatar Jan 08 '23 09:01 NikkTod

Hi @yury-s, assertThat(page).hasScreenshot(path) should suffice for our framework's needs. Eagerly waiting for this feature.

Tahanima avatar Feb 24 '23 07:02 Tahanima

Also giving it a star. Would be really good to have this also in java.

morepe avatar Mar 03 '23 07:03 morepe

We would really need this. We would like to avoid having java and nodejs separate modules just because this feature is not available in java atm.

mcturtle987 avatar Mar 03 '23 08:03 mcturtle987

Would also love to see this in Java

buzinator-be avatar May 30 '23 14:05 buzinator-be

Would love to see this feature!

flxtcha avatar Nov 08 '23 17:11 flxtcha

Is there any update on this topic? I would love to have it in Java.

jakubvojacek-wandera avatar May 31 '24 06:05 jakubvojacek-wandera