Module Based Framework

📚 Module Based Framework

The Module Based Framework separates test scripts into different modules.

📦 Modules

  • Each module contains code related to a specific area of the application under test.

  • For example, login module, home page module, user management module etc.

  • Modules consist of page objects, test cases, utilities etc.

👍 Benefits

  • Improves code reusability - Modules can be reused across tests and projects.

  • Easy to maintain - Changes remain within the module.

  • Organized structure - Logical separation makes code easy to navigate.

📃 Example modules for CNBC

// Login Page Module
public class LoginPage {

  // Locators
  By usernameLocator = By.id("username");
  By passwordLocator = By.id("password");
  By loginButtonLocator = By.id("login");
  
  // Methods to interact with page  
  public void enterUsername(String username) {
    driver.findElement(usernameLocator).sendKeys(username); 
  }
  
  public void enterPassword(String password) {
    driver.findElement(passwordLocator).sendKeys(password);
  }  
  
  public void clickLogin() {
    driver.findElement(loginButtonLocator).click(); 
  }
}

// Home Page Module 
public class HomePage {

  // Locators
  By welcomeTextLocator = By.id("welcome");
  By articlesLocator = By.className("articles");
  
  // Methods
  public String getWelcomeText() {
    return driver.findElement(welcomeTextLocator).getText();
  }  

  public int getArticlesCount() {
    return driver.findElements(articlesLocator).size();
  }

}

The module based framework is considered the most basic out of the other Selenium test automation frameworks for a few key reasons:

  • Structure - It has a simple and straightforward structure compared to other frameworks. The tests are just broken down into logical modules representing parts of the application.

  • Beginner Friendly - Module based framework is easy to understand for beginners and people new to Selenium. The modular approach allows working on small focused parts of the application.

  • Less Coding - Constructing modules only requires basic object-oriented code like creating classes and methods. No need for advanced concepts like external files, keywords etc.

  • Quick Implementation - Module based frameworks can be quickly set up and implemented even for small projects, requiring less initial time investment.

  • Minimal External Dependencies - It relies mostly on core Selenium and programming language capabilities. No need for additional libraries, tools or packages.

  • Less Maintenance - Since everything is contained within modules, minimal maintenance is needed compared to external data/keyword aspects of other frameworks.

  • Limited Reuse - Code reuse is generally limited to within the modules and not many concepts promote reuse across the framework.

So in summary, the simplicity, easy learning curve, quick setup and lack of external dependencies is why module based approach is considered the most basic Selenium automation framework. It serves as a good starting point for beginners.

Last updated