Welcome to the Playwright technical challenge!
Objective:
Your task is to review the existing Playwright test suite for https://practicesoftwaretesting.com, identify and fix issues within the tests and Page Objects and implement missing tests.
Website Under Test: https://practicesoftwaretesting.com
Tasks:
Part 1: Bug Fixing & Code Problems
Familiarise yourself with the Page Objects in the pages directory and the tests in the tests directory.
-
Review
tests/login.spec.tsand its correspondingpages/login.page.ts. There's an issue preventing login functionality tests from passing consistently. Identify and fix it (the bug might be in the spec file or the Page Object). -
In
tests/products.spec.tsand potentiallypages/products.page.tsorpages/productDetails.page.ts, the testAdd product to favorites and verifyis failing. Identify and fix it.
Part 2 by using Cursor: Missing Tests & Page Object Enhancements
-
In
pages/products.page.ts:- Implement the method
filterByCategory(categoryName: string). - Implement a method
getDisplayedProductNames(): Promise<string[]>orverifyProductsBelongToCategory(categoryName: string).
- Implement the method
-
In
tests/products.spec.ts:- Using the new methods in
ProductsPage, implement the testshould filter products by category. This test should:- Navigate to the product listing page.
- Use the
ProductsPageto select a product category (e.g., "Drills"). - Use the
ProductsPageto verify that only products belonging to that category are displayed.
- Using the new methods in
-
In
pages/cart.page.ts(or create if placeholder):- Add necessary locators for cart items (name, price, quantity, remove button).
- Implement methods like
getCartItemDetails(productName: string): Promise<{name: string, price: string, quantity: string}>,removeItem(productName: string). - Implement
getCartItemCount(): Promise<number>andisCartEmpty(): Promise<boolean>.
-
In
tests/cart.spec.ts(or create if placeholder):- Implement a test
should add a product to the cart and verify cart contentsusing methods fromProductDetailsPage(for adding to cart) andCartPage(for verification). - Implement a test
should increase product quantity in cartusingCartPagemethods. - Implement a test
should remove a product from the cartusingCartPagemethods. (Bonus)
- Implement a test
Evaluation Criteria:
- Correctness of bug fixes (in tests or Page Objects).
- Completeness and correctness of new tests and Page Object methods.
- Adherence to POM principles.
- Effectiveness of performance issue identification and proposed solutions.
- Code quality, readability, and use of Playwright best practices.
Good luck!