Skip to content

Commit

Permalink
Merge pull request #10 from JakubRumpca/test-case-05
Browse files Browse the repository at this point in the history
Test case 05: Failed login with wrong password
  • Loading branch information
JakubRumpca authored Jun 13, 2024
2 parents 94f396e + 1686ac1 commit 48d9825
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
28 changes: 28 additions & 0 deletions TEST_CASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,32 @@
- Three products are correctly added to the cart and displayed with accurate details.
- The removal process completes without errors.

---

## 5) Test Case: Failed login with wrong password

### Test Case ID:
- TC-05

### Test Case Name:
- Should check if the standard user can not log in using the wrong password.

### Test Objective:
- Verify that the standard user can not log in.

### Pre-conditions:
- The user has a valid account on the online store.
- The user knows their login credentials and purposely sets the wrong password.

### Steps:
- Open the web browser.
- Go to the online store's login page URL (https://www.saucedemo.com/).
- Fill username input (standard_user).
- Fill password input (wrongPassword).
- Verify the presence of a error message (Epic sadface: Username and password do not match any user in this service).

### Expected Results:
- The user can not logs in.
- The error message is displayed.

---
10 changes: 8 additions & 2 deletions tests/users.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { test, expect } from '@playwright/test';
import { LoginPage } from '../page_object/loginPage';

let loginPage: LoginPage
let loginPage: LoginPage;
const errorMessageLocator: string = '[data-test="error"]';

test.beforeEach(async ({page}) => {
loginPage = new LoginPage(page);
Expand All @@ -14,5 +15,10 @@ test('Should check if the standard user can log in', async ({ page }) => {

test('Should check if the locked user can not log in', async ({ page }) => {
await loginPage.login(process.env.LOCKED_USER, process.env.PASSWORD);
await expect(page.locator('[data-test="error"]')).toContainText('Epic sadface: Sorry, this user has been locked out.');
await expect(page.locator(errorMessageLocator)).toContainText('Epic sadface: Sorry, this user has been locked out.');
});

test('Should check if the standard user can not log in using the wrong password', async ({ page }) => {
await loginPage.login(process.env.STANDARD_USER, "wrongPassword");
await expect(page.locator(errorMessageLocator)).toContainText('Epic sadface: Username and password do not match any user in this service');
});

0 comments on commit 48d9825

Please sign in to comment.