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 145 forks source link

How to compare screenshots for a specific element? #316

Closed ivanqa2022 closed 1 year ago

ivanqa2022 commented 1 year ago

I put together a screenshot comparison command for elements, not for the whole page. Will this work correctly?

await expect(page.locator('.footer-position__logo-container')).toHaveScreenshot(`${g.name} webCheckFuter.png`);
ivanqa2022 commented 1 year ago

I checked this method works great.