Skip to content

Swag Labs Test Automation is a framework for automating tests of the Swag Labs eCommerce website. Built with Selenium WebDriver and Java, it uses Page Object Model (POM) for clean code, TestNG for test management, and ExtentReports for detailed reporting. Technologies: Selenium WebDriver, Java, TestNG, ExtentReports Design Pattern: POM

Notifications You must be signed in to change notification settings

SanjanaVarma12/swag-labs-test-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swag Labs Test Automation Framework

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.

Screen Record of Tests Running

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

Extent Report of Tests Running

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.

Extent Report Extent Report summary


Table of Contents

  1. Project Structure
  2. Technologies Used
  3. Pre-requisites
  4. Installation
  5. Execution
  6. Test Report
  7. GitLab Integration
  8. Adding New Tests
  9. Contributing

Project Structure

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

Technologies Used

  • 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.

Pre-requisites

  1. Java (version 8 or higher)
  2. Maven (version 3.6+)
  3. Git (for cloning the repository)
  4. Selenium WebDriver (managed by Maven)
  5. TestNG (included as a Maven dependency)
  6. Browser Drivers (ChromeDriver, FirefoxDriver, etc.)

Installation

  1. Clone the repository:
  2. 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>
    

Execution

Running Tests from Command Line

You can run the tests using Maven with the following command:

mvn test

Running Tests via TestNG

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.


Test Report

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

GitLab Integration

The project integrates with GitLab CI/CD for automated test execution.

  1. GitLab CI Pipeline: The .gitlab-ci.yml file defines the pipeline for running tests on every push to the repository.
  2. 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.

Adding New Tests

  1. 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.
  2. <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>
    

Contributing

To contribute:

  1. Fork the repository on GitLab.
  2. Create a feature branch.
  3. Commit your changes and push the branch.
  4. Submit a merge request for review.

Please adhere to the existing code structure and coding standards.


About

Swag Labs Test Automation is a framework for automating tests of the Swag Labs eCommerce website. Built with Selenium WebDriver and Java, it uses Page Object Model (POM) for clean code, TestNG for test management, and ExtentReports for detailed reporting. Technologies: Selenium WebDriver, Java, TestNG, ExtentReports Design Pattern: POM

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published