This project is a Test Automation Framework designed to automate the testing of the Swag Labs eCommerce website. The framework is built using Selenium WebDriver with Java, following the Page Object Model (POM) design pattern. TestNG is used as the testing framework, and ExtentReports is integrated for generating detailed test reports. The framework is managed through GitLab for version control, and Maven is used for dependency management and build automation.
The screen recording showcases the execution of test cases across multiple browsers, including Chrome, Firefox. The recording demonstrates that all test cases have successfully passed, ensuring consistent functionality and reliability of the Swag Labs eCommerce platform across different environments.
Screen.Recording.2024-09-05.at.3.23.52.PM.1.1.1.mov
This report provides a detailed summary of all the test cases executed, including pass/fail status, test duration, and additional logs. The ExtentReport offers a visually rich interface to review test execution results, enhancing transparency and making debugging more efficient. You can view the latest test summary by accessing the report.
- Project Structure
- Technologies Used
- Pre-requisites
- Installation
- Execution
- Test Report
- GitLab Integration
- Adding New Tests
- Contributing
The framework follows a modular and scalable structure:
src/ │ ├── main/ │ ├── java/ │ │ ├── base/ # Base classes for test setup/teardown │ │ ├── Locators/ # Locators for web elements │ │ ├── page objects/ # Page Object classes │ │ ├── test/ # Test-related classes │ │ └── Utils/ # Utility classes (helpers, WebDriver setup, etc.) │ ├── resources/ # Test data, configuration files ├── reports/ # ExtentReports output ├── pom.xml # Maven configuration └── testng.xml # TestNG configuration file
- Selenium WebDriver: Automates browser interactions for UI testing.
- Java: Core programming language for test scripting.
- TestNG: Testing framework for test execution and reporting.
- Maven: Build automation tool used for managing project dependencies and running tests.
- ExtentReports: Used for generating rich, interactive test reports.
- Page Object Model (POM): Design pattern for better maintainability and readability of code.
- GitLab: Version control for source code and continuous integration.
- Java (version 8 or higher)
- Maven (version 3.6+)
- Git (for cloning the repository)
- Selenium WebDriver (managed by Maven)
- TestNG (included as a Maven dependency)
- Browser Drivers (ChromeDriver, FirefoxDriver, etc.)
- Clone the repository:
git clone https:https://github.com/SanjanaVarma12/swag-labs-test-automation.git
<li><strong>Navigate to the project directory:</strong></li>
<pre><code>cd swag-labs-test-automation</code></pre>
<li><strong>Install dependencies using Maven:</strong></li>
<pre><code>mvn clean install</code></pre>
<li><strong>Configure browser drivers:</strong> Make sure the necessary browser drivers (e.g., ChromeDriver) are set up. You can either place the drivers in the system PATH or configure them in the <code>BaseTest</code> class.</li>
You can run the tests using Maven with the following command:
mvn test
You can also run tests using TestNG:
mvn test -DsuiteXmlFile=testng.xml
The testng.xml
file allows you to specify which tests to run, their order, and more.
ExtentReports generates detailed HTML reports after each test run. The reports are saved in the reports/
directory.
- Open the
ExtentReport.html
file in your browser to view test results. - The report includes:
- Test case status (Pass/Fail/Skip)
- Screenshots of failed tests
- Execution time details
The project integrates with GitLab CI/CD for automated test execution.
- GitLab CI Pipeline: The
.gitlab-ci.yml
file defines the pipeline for running tests on every push to the repository. - Continuous Integration:
- The pipeline is triggered upon changes to the repository.
- Tests are executed on the GitLab CI runners.
- Reports can be accessed via the GitLab pipeline results.
- Create Page Objects:
- Add new page classes in the
PageObjects.java
package. - Follow the POM structure by defining elements and actions related to each page.
- Add new page classes in the
<li><strong>Create Test Cases:</strong>
<ul>
<li>Write test cases in the <code>tests.java</code> package.</li>
<li>Maintain consistency with the existing test class structure.</li>
</ul>
</li>
<li><strong>Update TestNG:</strong> Add new tests to the <code>testng.xml</code> file for inclusion in test execution.</li>
<li><strong>Run Tests:</strong> Execute tests using the steps mentioned in the <a href="#execution">Execution</a> section.</li>
To contribute:
- Fork the repository on GitLab.
- Create a feature branch.
- Commit your changes and push the branch.
- Submit a merge request for review.
Please adhere to the existing code structure and coding standards.