QUESTION: How do I capture a reference after doing an action with playwright?
awhisler opened this issue · 2 comments
I have been googling for a few days and I cannot find this answer anywhere so I apologize this is more of a question then potentially an issue but the scenario
within the backstop.json is only relevant if I don't have to do some action before I capture the page screenshot. What if I need to log into an application before I can get the next scenario. How do I do this? I have a playwright application that logs into an application then I envisioned I needed to call something like "backstopCapture()" on the test file. Is this a thing? What am I missing here?
static async login({ page }, username: string) {
const emailFild = await page.locator(loginSelectors.email);
await emailFild.fill(username);
await page.getByRole('button').click();
const passwordField = await page.locator(loginSelectors.password);
await passwordField.fill(common.password);
await page.locator(loginSelectors.loginSubmit).click();
await expect(page.locator(loginSelectors.email)).toHaveCount(0); //logged in successfully
backstopCaptureScreenshot()
}
If not, how do I do this within the backstop.json?
You can use onReadyScript to perform actions before capturing the screenshot. Or you can use cookies as well for login.
@sreeram1985 thank you!! It does seem like it can't capture the login screen though now? I have one scenario for before it logs in
But again, is there a way for me to not do all the exact same actions that are in my playwright script and just capture references/scenarios as Im running my playwright tests?