You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{within}from'@playwright-testing-library/test/fixture';import{testasbaseTest}from'@playwright/test';import{locatorFixturesasfixtures,LocatorFixturesasTestingLibraryFixtures,}from'@playwright-testing-library/test/fixture';consttest=baseTest.extend<TestingLibraryFixtures>(fixtures);const{ expect }=test;test.only('sample test @regression',async({ page, queries })=>{awaitpage.goto('https://session.test.bbc.co.uk/session');constform=queries.queryByTestId('form');const{ queryByLabelText }=within(form);constidentifier=queryByLabelText('Email or username');awaitexpect(form).toHaveScreenshot('form-mask-identifier.png',{mask: [identifier],});});
Output:
Error: Timeout 10000ms exceeded.
Call log:
- expect.toHaveScreenshot with timeout 10000ms
- generating new stable screenshot expectation
- waiting for selector "query-by-test-id=["form"]"
- selector resolved to visible <form method="post" novalidate="" data-testid="form" a…>…</form>
- taking element screenshot
- disabled all CSS animations
- waiting for element to be visible and stable
- element is visible and stable
- failed to take screenshot - TypeError: Cannot read properties of undefined (reading 'queryByTestId')
at Object.queryAll (<anonymous>:5136:38)
at InjectedScript._queryEngineAll (<anonymous>:3889:49)
at InjectedScript.querySelectorAll (<anonymous>:3876:30)
at InjectedScript.maskSelectors (<anonymous>:4505:26)
at eval (eval at evaluate (:178:30), <anonymous>:4:16)
at UtilityScript.evaluate (<anonymous>:180:17)
at UtilityScript.<anonymous> (<anonymous>:1:44)
- waiting 100ms before taking screenshot
- waiting for selector "query-by-test-id=["form"]"
The text was updated successfully, but these errors were encountered:
The assertion (was introduced in 1.22.0):
https://playwright.dev/docs/test-assertions#locator-assertions-to-have-screenshot-1
package.json:
Playwright test config:
Minimal example:
Output:
The text was updated successfully, but these errors were encountered: