This project contains Playwright test cases for testing login functionality on the Practice Test Automation website using Playwright with TypeScript. The tests cover positive and negative login scenarios using the Page Object Model.
-
Positive LogIn Test
- Opens the login page.
- Types the username and password.
- Submits the form.
- Verifies that the new page URL contains
practicetestautomation.com/logged-in-successfully/
. - Checks that the page contains the expected success text ('Congratulations' or 'successfully logged in').
- Verifies that the "Log out" button is displayed.
-
Negative Username Test
- Opens the login page.
- Types an incorrect username and a valid password.
- Submits the form.
- Checks that an error message is displayed.
- Verifies that the error message text is 'Your username is invalid!'.
-
Negative Password Test
- Opens the login page.
- Types a valid username and an incorrect password.
- Submits the form.
- Checks that an error message is displayed.
- Verifies that the error message text is 'Your password is invalid!'.
Ensure that the following libraries are installed:
-
Clone the Repository
git clone <repository-url> cd <repository-directory>
-
Install Dependencies
npm install
-
Check
.env
File.env
file is already present in the root of project directory.
To run the test cases, use the following command:
npx playwright test
for specific test cases,
npx playwright test tests/login.spec.ts
For running test cases without headless,
npx playwright test --headless
login.spec.ts
: Contains the test cases for login functionality using Playwright.LoginPage.ts
: Page object class for the login page.LoggedInPage.ts
: Page object class for the logged-in page.ErrorPage.ts
: Page object class for the error page.
Feel free to fork the repository and submit pull requests. For any issues or suggestions, please open an issue on GitHub.