QA Interview Handbook
  • ๐Ÿ Home Page
  • About Testing
    • ๐Ÿ’–Qualities of A Great Tester
  • Manual Testing
    • ๐Ÿ’กOverview
      • โœ‹Demand for Software Testing
      • ๐Ÿ˜„Tester's Role in Manual Testing
      • 7๏ธTesting Principles
      • ๐ŸšจV & V
      • โ”Interview Questions
    • โ™ป๏ธSDLC
      • ๐Ÿ“’Phase 1: Planning
      • ๐Ÿ”Phase 2: Requirement Analysis
      • ๐Ÿ‘”Phase 3: Design
      • โ›‘๏ธPhase 4: Development
      • ๐ŸงชPhase 5: Testing
      • ๐ŸššPhase 6: Deployment
      • ๐Ÿ–ฑ๏ธPhase 7: Maintenance
      • โš”๏ธCommon Challenges
      • โ”Interview Questions
    • ๐ŸŒ€STLC
    • ๐ŸŒŠWaterfall
    • โœณ๏ธAgile
      • ๐Ÿ˜Tester's Role in Scrum
    • ๐Ÿ”ขTypes
      • โฌœWhite Box Testing
      • โฌ›Black Box Testing
        • ๐Ÿ”ฐTechniques Used in Black Box Testing
        • ๐Ÿš˜Functional Testing
          • 1๏ธโƒฃUnit Testing
          • 2๏ธโƒฃIntegration Testing
            • ๐Ÿ”ฐTechniques Used in Integration Testing
          • 3๏ธโƒฃSystem Testing
            • ๐Ÿ“ผTypes of System Testing
            • ๐ŸŒŠPhases of System Testing
            • ๐ŸŒ€Regression Testing
            • ๐ŸŒซ๏ธSmoke Testing
          • 4๏ธโƒฃAcceptance Testing
            • โš™๏ธUser Acceptance Testing
            • ๐Ÿ…ฐ๏ธAlpha Testing
            • ๐Ÿ…ฑ๏ธBeta Testing
        • ๐Ÿ•ณ๏ธNon Functional Testing
      • ๐Ÿ“‘Grey Box Testing
    • ๐Ÿช„User Story
      • โบ๏ธSample User Stories
    • ๐Ÿ““Test Cases
      • โบ๏ธSample Test Cases
      • โ”Interview Questions
    • โœ–๏ธDefect Life Cycle
      • โ˜ฃ๏ธPriority + Severity
      • โบ๏ธSample Defect Reports
      • โ”Interview Questions
      • ๐Ÿ›Buggy Questions
    • ๐ŸŒAtlassian JIRA
      • ๐ŸžJIRA Issues
      • โ”Interview Questions
    • โ”Interview Questions
  • Accessibility Testing
    • ๐Ÿ’กOverview
    • ๐Ÿค“Tester's Role in Accessibility Testing
    • ๐Ÿ“šWCAG Principles
      • ๐Ÿ‘๏ธPerceivable
      • ๐ŸนOperable
      • ๐Ÿง Understandable
      • ๐Ÿค–Robust
    • ๐Ÿ”งAxe DevTools
      • โ”Interview Questions
    • ๐Ÿ““Test Cases
    • โ”Interview Questions
  • API Testing
    • ๐Ÿ’กOverview
    • ๐Ÿ˜€Tester's Role in API Testing
    • ๐ŸŠHTTP Methods & CRUD
      • ๐Ÿ‚HTTP Status Codes
    • ๐ŸAPI Tools
      • ๐ŸŸ Postman
        • โ˜„๏ธSending your first API request
        • ๐Ÿ”ฌHTTP Requests with Java
        • ๐ŸŽฒGitHub Sample
        • โ”Interview Questions
      • โ›‘๏ธREST Assured
        • ๐ŸŽ‡Dependency
        • โ”Interview Questions
    • ๐Ÿ““Test Cases
    • ๐ŸฆงAPI Cheatsheet
    • โ”Interview Questions
  • Database Testing
    • ๐Ÿ’กOverview
    • ๐Ÿ˜†Tester's Role in Database Testing
    • ๐Ÿ”ตSQL
      • โ›“๏ธConstraints
      • ๐Ÿ›ข๏ธReferencing a Column
      • ๐Ÿ”ผDDL Commands
      • ๐Ÿ”ผDML Commands
        • ๐Ÿ–Œ๏ธOperators
        • ๐Ÿ› ๏ธFunctions
          • โฏ๏ธAggregate Functions
        • ๐ŸŽ…Clauses
          • โซJoin Clauses
          • ๐Ÿ”ตFilter Clauses
          • โฌSet Operations
      • ๐ŸƒWildcard Character
      • โ”Interview Questions
    • ๐Ÿ““Test Cases
    • ๐ŸงคSQL Practice Sites
    • ๐ŸซSQL Cheatsheet
    • โ”Interview Questions
  • Java
    • โ›ฉ๏ธIntroduction
    • ๐Ÿ˜„Tester's Reason to Learn Java
    • โ“‚๏ธMain Method
      • โ”Interview Questions
    • ๐Ÿ“Variables & Types
      • ๐ŸชขSpecial Types
    • ๐ŸฅModifiers
    • ๐Ÿ…พ๏ธOperators
    • ๐ŸชกString
      • ๐ŸฉบString Methods
        • String Method Problems
      • ๐ŸšจDelimiter
      • โ”Interview Questions
    • ๐Ÿ–‡๏ธConditionals
      • ๐Ÿ’ŽCommon If Statements
      • ๐Ÿ’ŽCommon Ternary Operator Statements
    • โ“‚๏ธMath Class
    • ๐ŸŒŠLoops
      • ๐Ÿ’ŽCommon Loop Examples
      • ๐Ÿ”ƒNested For Loops
    • ๐ŸผOOPS
      • ๐Ÿ›๏ธClasses and Objects
        • โ”Interview Questions
      • ๐ŸŽƒConstructor
        • โšกStatic
          • โ”Interview Questions
        • ๐Ÿ“This() & Super()
          • โ”Interview Questions
        • ๐Ÿ€Finalization
      • ๐Ÿ”“Encapsulation
      • ๐ŸฅInheritance
      • ๐Ÿฆ‹Polymorphism
      • ๐Ÿ•ธ๏ธAbstraction
    • ๐ŸฎJava Practice Sites
    • โ˜‘๏ธData Structures + Algorithms
      • ๐Ÿ…พ๏ธBig O
      • โ˜‘๏ธData Structures
        • ๐Ÿ”ธArray
        • ๐Ÿ”ณArray Problems
        • Page
      • ๐ŸชŸSliding Window Technique
        • ๐ŸชŸSliding Window Problems
        • ๐ŸฅLeetCode #53
        • ๐ŸฅLeetCode #209
    • โ”Interview Questions
  • Automation Testing
    • ๐ŸšฐFlow
      • ๐Ÿ’กOverview
      • ๐ŸคฉTester's Role in Automation Testing
      • ๐Ÿ€Selenium
        • ๐Ÿ•ธ๏ธSelenium WebDriver
          • ๐Ÿ•ท๏ธWebDriver Commands
            • ๐ŸŒWebElement
              • ๐Ÿ”†HTML Tags
              • ๐Ÿ”ฌFind Element(s)
              • ๐ŸฆŽLocators
                • โŒXpath
                • ๐ŸฐCSS Selector
                • ๐Ÿ“€DOM
                • ๐Ÿ Quick Reference for XPath + CSS
            • โœ‹Waits
            • Browser Management
            • ๐ŸŽ๏ธNavigation
            • Alerts
          • ๐Ÿท๏ธAdvanced User Interactions
            • ๐Ÿ—ฏ๏ธAction vs. Actions
            • ๐Ÿ’งDrop Down
            • โœ…Check Box
            • ๐Ÿ–‡๏ธForms
          • โš ๏ธExceptions
        • ๐ŸOOPS + Selenium
        • ๐ŸšขFrameworks
          • โš“Module Based Framework
          • ๐ŸŽนKeyword Driven Framework
          • ๐ŸŽ‹Data Driven Framework
          • ๐ŸŒบHybrid Framework
          • ๐ŸŒดLog4j
          • ๐Ÿ“„Page Object Model
        • ๐ŸงชTesting Frameworks
          • ๐Ÿ’กTestNG
          • ๐Ÿ‰‘JUnit
          • ๐Ÿฅ’BDD
            • ๐Ÿฅ’Cucumber
        • ๐ŸŒ‰Selenium Grid
          • โœ–๏ธDesired Capabilities
        • โ”Interview Questions
      • ๐Ÿ”„API Testing with Selenium
      • โชDatabase Testing with Selenium
      • โ“‚๏ธMaven
      • ๐Ÿ™Git
        • โ”Interview Questions
      • ๐Ÿ•ต๏ธโ€โ™‚๏ธJenkins
        • โ”Interview Questions
      • ๐ŸณDocker
        • โ”Interview Questions
      • ๐Ÿ“™AWS
        • โ”Interview Questions
  • Behavioral
    • ๐Ÿ“ฃMixed Interview Questions
    • โญSTAR Method
      • ๐ŸŒŸSample Responses
Powered by GitBook
On this page
  • ๐Ÿ“š Data Driven Framework - Expert Guide
  • ๐Ÿ“Š Externalizing Test Data
  • ๐Ÿ— Reading Test Data
  • ๐Ÿงช Multiple Iterations

Was this helpful?

  1. Automation Testing
  2. Flow
  3. Selenium
  4. Frameworks

Data Driven Framework

Here is an in-depth expert level explanation of the Data Driven framework with a complex example for CNBC using Java:

๐Ÿ“š Data Driven Framework - Expert Guide

The Data Driven framework separates test data from test logic for maximum reusability.

๐Ÿ“Š Externalizing Test Data

  • Test data is stored in external sources like:

    • JSON

    • XML

    • Databases

    • Excel (XLS, XLSX)

    • CSV

    • Config files

  • Allows managing data separately from scripts.

  • JSON and Databases provide structured storage.

๐Ÿ— Reading Test Data

  • Test scripts use a Reader class to access external data.

  • Readers implemented for each data source e.g. JSONReader, DBReader etc.

-decouples test scripts from underlying data storage.

๐Ÿงช Multiple Iterations

  • Scripts can loop through data sets using for loops.

  • Each iteration executes same test steps with different data.

  • Runs expand easily by adding data records.

๐Ÿ”Ž Using an External Database in Data Driven Framework

In a Data Driven Framework, the test data can be stored in various external data sources, including databases. Using an external database as the data source provides several benefits, such as centralized data management, easy data retrieval, and the ability to handle large data sets. Here's how an external database can be used in a Data Driven Framework:

  1. Database Connection: The test script establishes a connection to the external database using a JDBC driver. The connection string contains the database URL, username, and password. Once the connection is established, the test script can execute SQL queries to retrieve the test data[1][4][5].

  2. SQL Query Execution: The test script executes SQL queries to retrieve the test data from the external database. The SQL queries can be customized to retrieve specific data based on the test requirements. The retrieved data is stored in variables in the test script for further processing[1][4][5].

  3. Test Script Execution: The test script uses the test data retrieved from the external database to perform the corresponding actions. The test execution engine or the automation framework interprets the test data and executes the associated functions or actions defined in the test script. The test script uses the test data from the external database as inputs for the actions performed during the test execution[1][4][5].

๐Ÿ‘จโ€๐ŸŽ“ Example for CNBC

Here's an example Java block for a Data Driven Framework that automates the end-to-end flow of the CNBC website using an external MySQL database as the data source:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class CNBCDataDrivenFramework {
    public static WebDriver driver;

    public static void main(String[] args) throws SQLException {
        System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
        driver = new ChromeDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        String url = "jdbc:mysql://localhost:3306/testdata";
        String username = "root";
        String password = "password";

        Connection connection = DriverManager.getConnection(url, username, password);
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT * FROM users");

        while (resultSet.next()) {
            String username = resultSet.getString("username");
            String password = resultSet.getString("password");
            String stock = resultSet.getString("stock");

            driver.get("https://www.cnbc.com/");
            driver.manage().window().maximize();

            // Login
            driver.findElement(By.linkText("Sign In")).click();
            driver.findElement(By.id("username-verification")).sendKeys(username);
            driver.findElement(By.id("password-verification")).sendKeys(password);
            driver.findElement(By.id("login-button")).click();

            // Search for a stock
            driver.findElement(By.id("header-search")).sendKeys(stock);
            driver.findElement(By.id("header-search-button")).click();

            // Logout
            driver.findElement(By.linkText("Sign Out")).click();

            driver.quit();
        }

        resultSet.close();
        statement.close();
        connection.close();
    }
}

This Java block automates the following actions:

  1. Open the CNBC website.

  2. Click on the "Sign In" link.

  3. Enter the username and password.

  4. Click on the "Login" button.

  5. Search for a stock.

  6. Click on the "Sign Out" link.

  7. Close the browser.

The test data used in this example is stored in an external MySQL database named "testdata". The database contains a table named "users" with three columns: username, password, and stock. The test script reads the test data from the database and uses it to perform the corresponding actions.

Using an external database as the data source provides several benefits, such as centralized data management, easy data retrieval, and the ability to handle large data sets. It also allows for easy modification and customization of test cases without the need to modify the underlying code. Testers can update the test data in the database, enabling quick changes to the test script behavior[1][4][5].

It's important to note that the specific components and their implementation may vary depending on the testing tool or framework being used. The examples provided in the search results demonstrate different approaches to implementing a Data Driven Framework using various tools and technologies.

PreviousKeyword Driven FrameworkNextHybrid Framework

Last updated 1 year ago

Was this helpful?

๐Ÿšฐ
๐Ÿ€
๐Ÿšข
๐ŸŽ‹