Skip to content

UmarNasib/SeleniumWebAutomation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selenium Test Automation Framework

A robust, generic, and reusable Selenium WebDriver framework designed for scalability and ease of use. This project implements the Page Object Model (POM) pattern and supports data-driven testing using TestNG and CSV files.

🏗 Project Structure

.
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   ├── config/          # Configuration and Report management
│   │   │   ├── driver/          # Browser and Driver lifecycle management
│   │   │   ├── data/            # Generic Data models for test cases
│   │   │   ├── page/            # Base Page and Page Object classes
│   │   │   └── util/            # Shared web and global utilities
│   │   └── resources/
│   │       └── general.properties # Environment and browser settings
│   └── test/
│       ├── java/
│       │   ├── test/            # Actual Test Classes
│       │   └── util/            # Base Test, Listeners, and Data utilities
│       └── resources/
│           └── testData/        # CSV files for Data-Driven testing
├── build.gradle                 # Dependency and task management
└── README.md                    # Project documentation

🚀 Getting Started

Prerequisites

  • Java JDK 11 or higher.
  • Gradle (installed or via the included wrapper).

Configuration

Update the src/main/resources/general.properties file with your environment details:

  • browser: Specify the browser (e.g., chrome, firefox).
  • base.url: The URL of the application under test.
  • timeout: Implicit wait duration in seconds.
  • headless: Set to true to run tests without a browser UI.

Running Tests

Execute the following command in the terminal to run all tests:

./gradlew test

🛠 How to Use

1. Adding a New Page Object

  1. Create a new class in the page package that extends BasePage.
  2. Use @FindBy annotations to identify WebElements.
  3. Add methods for user actions following the naming conventions below.

2. Adding a New Test

  1. Create a test class in the test package that extends BaseTest.
  2. Implement the initialize() method to instantiate the required page objects using the createInstance() factory method.
  3. Annotate your test methods with TestNG's @Test.

3. Data-Driven Testing

  1. Add a CSV file to src/test/resources/testData/.
  2. Create a data model in src/main/java/data/ that extends BaseData.
  3. Use TestDataUtils.loadData() to read the file contents into your test.

📏 Coding Conventions

File Header Documentation Standard

Each .java file should begin with the following comment block:

/**
 * @author Abdullah Umar Nasib
 * @since 12/02/2026
 */

Naming convention for Selenium WebElements

Element Prefix Example
Button btn btnSave
Check box chk chkTerms
Dropdown list ddl ddlCountry
Link lnk lnkForgotPassword
Text box txt txtFirstName

Naming convention for methods

Actionable Element Prefix Example
Button click clickSave()
Dropdown list select selectCountry()
Text box enter enterFirstName()

📊 Reporting & Screenshots

  • ExtentReports: Rich HTML reports are generated automatically in the report/ folder.
  • Screenshots: Upon test failure, the framework automatically captures a screenshot and embeds it into the ExtentReport.
  • Formatting: Code formatting is managed via google-java-format.

📦 Key Dependencies

  • Selenium Java: Web automation core.
  • WebDriverManager: Automatic driver binary management.
  • TestNG: Testing framework.
  • Owner: Property file mapping.
  • ExtentReports: Reporting library.
  • Lombok: Reducing boilerplate code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages