Graff
Graff
TTCTheo's Typesafe Cult
Created by Rezix on 1/18/2024 in #questions
Frontent Testing Framework
If you can and you haven't already, I highly recommend utilizing the built-in report from playwright via 'npx playwright show-report'. Playwright trace files are awesome for seeing exactly what happened in your tests.
12 replies
TTCTheo's Typesafe Cult
Created by Rezix on 1/18/2024 in #questions
Frontent Testing Framework
EG:
// Navigate to the login page
await page.goto('https://example.com/login');

const usernameLocator = page.locator('input[name="username"]');
const passwordLocator = page.locator('input[name="password"]');
const un = 'your_username';
const pw = 'your_password';
// Fill in the username and password
await usernameLocator.fill(un);
await expect(usernameLocator).toHaveValue(un);
await passwordLocator.fill(pw);
await expect(passwordLocator).toHaveValue(pw);
// ...the rest
// Navigate to the login page
await page.goto('https://example.com/login');

const usernameLocator = page.locator('input[name="username"]');
const passwordLocator = page.locator('input[name="password"]');
const un = 'your_username';
const pw = 'your_password';
// Fill in the username and password
await usernameLocator.fill(un);
await expect(usernameLocator).toHaveValue(un);
await passwordLocator.fill(pw);
await expect(passwordLocator).toHaveValue(pw);
// ...the rest
12 replies
TTCTheo's Typesafe Cult
Created by Rezix on 1/18/2024 in #questions
Frontent Testing Framework
It also might be worthwhile to add assertions in between each page.fill to ensure the input actually gets the values you want it to. Not necessarily useful for your intended test, but could be helpfull with debugging your login subroutine.
12 replies
TTCTheo's Typesafe Cult
Created by Rezix on 1/18/2024 in #questions
Frontent Testing Framework
This is a guess, but something I've seen before is that the event handler for forms (like login) will expect inputs to get/lose focus, or otherwise receive events that playwright injecting values will not trigger. Personally, if you can do a login by hand and watch for the ajax call, it'd probably be easier to just do the login API directly and not bother with the login screen.
12 replies
TTCTheo's Typesafe Cult
Created by Rezix on 1/18/2024 in #questions
Frontent Testing Framework
I'd be curious what kinds of cookie/auth issues you had in playwright, as that's what I would have recommended as I skimmed what you wrote. Applitools Eyes might also be worth a look.
12 replies