microsoft / playwright-java

Java version of the Playwright testing and automation library
https://playwright.dev/java/
Apache License 2.0
1.16k stars 209 forks source link

[Feature] Visual comparisons port to java library #1040

Open kabhinav26 opened 2 years ago

kabhinav26 commented 2 years ago

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
yury-s commented 2 years ago

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?

kabhinav26 commented 2 years ago

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 commented 2 years ago

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.

tsachi368 commented 2 years ago

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

assertThat(page).hasScreenshot(path)

NikkTod commented 1 year ago

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? :)

Tahanima commented 1 year ago

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

morepe commented 1 year ago

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

mcturtle987 commented 1 year ago

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.

abuze-tecovin commented 1 year ago

Would also love to see this in Java

flxtcha commented 1 year ago

Would love to see this feature!

jakubvojacek-wandera commented 6 months ago

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

andersens1 commented 3 weeks ago

I would really like this feature to be ported, to avoid importing extra 3rd party libraries. +1!

youvegotnigel commented 3 weeks ago

+1

xgidiussenjensent-els commented 3 weeks ago

We also need to be able do visual comparisons in playwright-java and it would be really nice to not have to resort to 3rd party libraries.