import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;// Full-page visual comparison:
assertThat(page).hasScreenshot("homepage-baseline.png");
// Element-specific visual comparison (e.g. checkout card):
Locator paymentCard = page.locator("#payment-card");
assertThat(paymentCard).hasScreenshot("payment-card-baseline.png");
page.locator(".timestamp-badge").evaluate("node => node.style.visibility = 'hidden'");