This repository contains a series of automated tests written using Playwright for a React web application by Fetch. The tests cover various functionalities of the application, including button clicks, input validation, and the identification of a fake gold bar using a binary search algorithm.
git clone https://github.com/SiDDyy007/SDET_Assessment.git
cd SDET_Assessment
npm install
Playwright tests can be run in a UI mode for better visualization of the test execution.
npx playwright test --ui
This command runs the tests in a browser window, allowing you to see the tests as they are being executed.
Each test file in this repository is designed to cover specific aspects of the application:
-
buttonClicks.spec.js: This test ensures that the 'Weigh' and 'Reset' buttons on the application are clickable and functioning as expected.
-
bowlFilling.spec.js: This test automates the process of filling in the left and right bowl grids with numbers and checks if the inputs are correctly populated.
-
weighingList.spec.js: This test focuses on the functionality of the weighing list. It verifies whether the list gets updated correctly upon weighing the bowls.
-
barClick.spec.js: This test simulates the clicking of gold bar buttons and checks for the appearance of alert messages, ensuring each button triggers the correct response.
-
findFakeBar.spec.js: This test implements a binary search algorithm to identify the fake gold bar. The algorithm splits the set of bars into groups, compares their weights, and narrows down the search for the fake bar based on the weighing results.
In the findFakeBar.spec.js file, a binary search algorithm is utilized to efficiently find the fake gold bar. The algorithm works as follows:
- Initially, it divides the set of gold bars into two groups and weighs them.
- If both groups weigh the same, the remaining bar (not in either group) is identified as the fake one.
- If there is a weight difference, it further divides the lighter group and repeats the process.
- This process continues until the fake gold bar, which weighs less, is isolated.