Skip to content

Instantly share code, notes, and snippets.

@nadvolod
Last active February 1, 2023 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadvolod/76be1456544c7a40e843004af664f038 to your computer and use it in GitHub Desktop.
Save nadvolod/76be1456544c7a40e843004af664f038 to your computer and use it in GitHub Desktop.
Flawed automated playwright tests
test('Dashboard page should not have any WCAG A violations', async ({ page }) => {
const authentication = new Authentication(page);
const loginPage = new LoginPage(page);
const dashboardPage = new DashboardPage(page);
await loginPage.login(user)
// Wait until the logo is visible - default 30000
await dashboardPage.waitForLogo()
await page.getByRole('button', { name: 'Log In' }).click();
await authentication.loginWith2FA(user)
await expect(loginPage.isErrorPresent()).toBeTruthy();
await expect(loginPage.invalidUsernameIcon.toBeVisible()).toBeTruthy();
// await expect(page.locator('#invalid-username-icon')).toBeVisible()
// await expect(page.locator('#invalid-password-icon')).toBeVisible()
// better approach
await expect(dashboardPage.toBeLoaded());
// bad approach
// await page.waitForSelector(dashboardPage.logoTxt, {timeout: 30000});
expect(await dashboardPage.getViolationsWithTags(tags)).toEqual([]);
});
test('Login with valid data', async ({page}) => {
const loginPage = new LoginPage(page);
const authentication = new Authentication(page);
const dashboardPage = new DashboardPage(page);
await loginPage.login(user)
await authentication.loginWith2FA(user)
expect(dashboardPage.isLogoVisible()).toBeTruthy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment