Skip to content

Commit c4f7c0f

Browse files
committed
Negative path tests
1 parent d85947c commit c4f7c0f

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

pages/login-page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class LoginPage{
77
readonly continueButton: Locator;
88
readonly continue: Locator;
99
readonly invalidUserError: Locator;
10+
readonly invalidPasswordError: Locator;
1011

1112
constructor(page: Page){
1213
this.page = page;
@@ -15,6 +16,7 @@ export class LoginPage{
1516
this.passwordInput = page.getByRole('textbox', { name: 'Password' });
1617
this.continue = page.getByRole('button', { name: 'Continue'});
1718
this.invalidUserError = page.getByText('Enter a valid email');
19+
this.invalidPasswordError = page.getByText('Your email or password is incorrect. Try again.');
1820
}
1921

2022
async fillEmail(email: string){
@@ -53,6 +55,10 @@ export class LoginPage{
5355
async verifyInvalidUserLogin(){
5456
await expect(this.invalidUserError).toBeVisible();
5557
}
58+
59+
async verifyInvalidPassword(){
60+
await expect(this.invalidPasswordError).toBeVisible();
61+
}
5662
}
5763

5864
export default LoginPage;

tests/login.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ let loginPage: LoginPage;
77
const password = process.env.PASSWORD!;
88
const username = process.env.USERNAME!;
99
const invalidUser = userData.INVALID_USER;
10+
const invalidPassword = userData.INVALID_PASSWORD;
1011

1112
test.beforeEach(async ({ page }) => {
1213
await page.goto('./login');
@@ -19,8 +20,13 @@ test.beforeEach(async ({ page }) => {
1920
await loginPage.verifyLogin();
2021
});
2122

22-
test(`unsuccessful login`, async () => {
23+
test(`unsuccessful login -invalid user email`, async () => {
2324
await loginPage.loginWithInvalidUser(invalidUser);
2425
await loginPage.verifyInvalidUserLogin();
2526
});
27+
28+
test(`unsuccessful login -invalid password`, async () => {
29+
await loginPage.doLogin(username, invalidPassword);
30+
await loginPage.verifyInvalidPassword();
31+
});
2632
});

0 commit comments

Comments
 (0)