playwright-community / playwright-go

Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
https://playwright-community.github.io/playwright-go/
MIT License
1.94k stars 144 forks source link

Visual comparisons #413

Closed ivaylo321 closed 4 months ago

ivaylo321 commented 4 months ago

There are two methods toHaveScreenshot and toMatchSnapshot described in this doc: https://playwright.dev/docs/test-snapshots

From what I see they are not implemented in the Go version of Playwright - are there plans to do so?

I am trying to implement something similar myself. For the images I am thinking about creating a screenshot and then using the Go image and color packages to compare it with an expected image, from what I understand I should be able to compare the images pixel by pixel this way. I would be grateful if someone has already done something similar and is willing to share an example.

canstand commented 4 months ago

Doc metions using pixelmatch, here is a go port, try using it.

canstand commented 3 months ago

Now tests/helper_test.go has AssertToBeGolden for visual comparison.