</>

Technology

Selenium

Difficulty

Intermediate

Interview Question

What is a data driven framework?

A data driven framework separates test data from test logic, allowing the same test to run with multiple data sets from external files.

Answer

A Data Driven Framework is one in which the test data is stored in external files (CSV, Excel, JSON, database) and is completely separated from the test logic written in test scripts. The test data drives the test cases — i.e., the test methods run once for each set of test data values.

How it works:

CODE
External Data (Excel/CSV) → Test Framework → WebDriver → Browser
     ↓                           ↓
  [admin, pass1]            Login test runs for row 1
  [user2, pass2]            Login test runs for row 2
  [guest, pass3]            Login test runs for row 3

Benefits:

  • Same test script runs with many data combinations
  • No need to write separate test methods for each data set
  • Easy for business teams to add new data without touching code

TestNG DataProvider example:

Java
@DataProvider(name = "loginData")
public Object[][] getData() {
    return new Object[][] {
        {"admin",  "pass123"},
        {"user2",  "test456"},
        {"guest",  "guest789"}
    };
}

@Test(dataProvider = "loginData")
public void testLogin(String username, String password) {
    driver.findElement(By.id("username")).sendKeys(username);
    driver.findElement(By.id("password")).sendKeys(password);
    driver.findElement(By.id("loginBtn")).click();
}

Reading from Excel (Apache POI):

Java
FileInputStream file = new FileInputStream("testdata.xlsx");
Workbook workbook = new XSSFWorkbook(file);
Sheet sheet = workbook.getSheet("LoginData");

Follow AutomateQA

Related Topics