Visitar URL original
[Feature] Visual comparisons port to java library · Issue #1040 · microsoft/playwright-java · GitHub
Skip to content

[Feature] Visual comparisons port to java library #1040

Description

@kabhinav26

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

Activity

  1. yury-s commented on Aug 31, 2022

    @yury-s
    Member

    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?

  2. kabhinav26 commented on Sep 5, 2022

    @kabhinav26
    Author

    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');

  3. kabhinav26 commented on Sep 5, 2022

    @kabhinav26
    Author

    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.

  4. tsachi368 commented on Oct 31, 2022

    @tsachi368

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

    assertThat(page).hasScreenshot(path)

  5. NikkTod commented on Jan 8, 2023

    @NikkTod

    Hello Yury Semikhatsky (@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? :)

  6. Tahanima commented on Feb 24, 2023

    @Tahanima

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

  7. morepe commented on Mar 3, 2023

    @morepe

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

  8. mcturtle987 commented on Mar 3, 2023

    @mcturtle987

    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.

  9. buzinator-be commented on May 30, 2023

    @buzinator-be

    Would also love to see this in Java

  10. flxtcha commented on Nov 8, 2023

    @flxtcha

    Would love to see this feature!

  11. jakubvojacek-wandera commented on May 31, 2024

    @jakubvojacek-wandera

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

  12. andersens1 commented on Oct 31, 2024

    @andersens1

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

  13. youvegotnigel commented on Nov 1, 2024

    @youvegotnigel

    +1

  14. xgidiussenjensent-els commented on Nov 1, 2024

    @xgidiussenjensent-els

    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.

  15. thulasipavankumar commented on Jun 17, 2025

    @thulasipavankumar

    +1
    would be a great feature

  16. CrepeClown commented on Jun 17, 2025

    @CrepeClown

    +1 Would love to see this added to playwright-java

  17. ksn5 commented on Oct 2, 2025

    @ksn5

    +1

  18. nstreltsov commented on Nov 25, 2025

    @nstreltsov

    +1

  19. nobesio commented on Dec 22, 2025

    @nobesio

    +1

  20. salpelter commented on Feb 22, 2026

    @salpelter
  21. jack5github commented on Mar 2, 2026

    @jack5github

    I have been attempting to implement visual comparisons manually, and have been finding that the screenshots from Java Playwright vary in colours, positions and dimensions, while those from TypeScript do not. A first-party solution for visual comparisons in Java would be much appreciated.

  22. leluna commented on Jun 22, 2026

    @leluna

    It would also help to have a BufferedImage instead of a byte array as it is much easier to obtain pixel data.

  23. anilreddy commented on Jul 22, 2026

    @anilreddy

    Yury Semikhatsky (@yury-s) can you please check the PR review it and merge if it is good?

  24. anilreddy commented on Aug 4, 2026

    @anilreddy

    Yury Semikhatsky (@yury-s) Please let me know if you want to assign this ticket to me or someone else anything is fine for me. Thanks

  25. ksn5 commented on Aug 6, 2026

    @ksn5

    Yury Semikhatsky (@yury-s) +1 for this feature. It would be really useful for our use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions