Skip to content

Test Automation Framework developed using Selenium WebDriver in Java.

Notifications You must be signed in to change notification settings

jovanovicbogdan/AutomationFramework

Repository files navigation

Test Automation Framework

  • Based on POM design pattern
  • Data Driven Testing approach
  • Used for functional UI testing

Prerequisites

  • Gradle build tool 7.4.2
  • Java 17 (if you are using Windows set JAVA_HOME environment variable to point to jdk root folder e.g. C:\Program Files\Java\jdk-17.0.2)
  • Environment Variables

Dependencies

  • Dependencies are managed by Gradle and they are declared in build.gradle in root project folder
  • Selenium = '4.1.3' - For browser automation
  • WebDriverManager = '5.1.0' - Download, setup, and maintenance of the drivers required by Selenium WebDriver
  • TestNG = '7.5' - Testing framework on which the tests are being executed
  • Apache POI = '5.2.2' - Library for parsing and working with Excel files in Java
  • log4j = '2.17.2' - Logging library

Project Structure

  • src/test/java/containers used for storing test session data and instantiated page object models
  • src/test/java/helpers generic functions, annotation processors and UI helper functions
  • src/test/java/poms page object models representing actual web pages
  • src/test/java/providers data providers for Data Driven Testing approach
  • src/test/java/runners TestNG runners

How to Run Tests

  • Before running tests make sure you have entered correct test parameters in src/test/resources/testParameters.xlsx Excel file (supported browser are either chrome or firefox)
  • After providing test parameters then you can enter keywords for each search engine in src/test/resources/testData.xlsx Excel file (note that Excel sheet name represents search engine)
  • If you have locally set up gradle binary then you can cd into project root and run the tests by command gradle clean test
  • If you do not have installed gradle binary locally then you can cd into project root folder and use gradlew (gradle wrapper) instead ./gradlew clean test

Logs

  • Logs can be found in /logs/SearchEngine.log file
  • It will be generated after test execution
  • Common results will be logged only if the same keyword is used for both search engines
  • Note that if you execute tests in a row few times it will append results to a log file

Workflow

  • Framework was developed in a way that allows new contributors to a project to easily add tests without any overlapping or potential conflicts
  • Example workflow (adding a new search engine) would be the following:
  1. Add search engine test data in src/test/resources/testData.xlsx file
  2. Add data provider class in src/test/java/providers e.g. NewSearchEngineDataProvider.java
public class NewSearchEngineDataProvider {
    @DataProvider(name = "NewSearchEngine")
    public static Object[][] getDuckDuckGoKeywordsData() {
        // NewSearchEngine is sheet name in testData.xlsx file
        return ExcelHelper.getTestData("NewSearchEngine");
    }
}
  1. Add new Page Object Model class in src/test/java/poms package e.g. NewSearchEngineHomePage.java (which extends BasePageObject.java class) and all corresponding methods to that particular web page
public class NewSearchEngineHomePage extends BasePageObject {
    @FindBy(css = "input[name=\"q\"]")
    WebElement searchInput;
    
    public NewSearchEngineHomePage(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(driver, this);
    }

    public void searchByKeyword(String keyword) {
    }
}
  1. Add newly created pom to a src/test/java/containers/PomContainer.java class
public class PomContainer {
    public GoogleHomePage googleHomePage;
    public DuckDuckGoHomePage duckDuckGoHomePage;
    public NewSearchEngineHomePage newSearchEngineHomePage;

    public PomContainer(WebDriver driver) {
        this.googleHomePage = annotatePOM(new GoogleHomePage(driver));
        this.duckDuckGoHomePage = annotatePOM(new DuckDuckGoHomePage(driver));
        this.newSearchEngineHomePage = annotatePOM(new NewSearchEngineHomePage(driver));
    }
}
  1. Add new test runner class in src/test/java/runners package e.g. NewSearchEngineTestRunner.java and it will extend Hooks.java class
public class NewSearchEngineTestRunner extends Hooks {

    @Test(dataProvider = "NewSearchEngine", dataProviderClass = NewSearchEngineDataProvider.class)
    public void searchNewSearchEngine(String keyword) {
        pages.newSearchEngineHomePage.searchByKeyword(keyword);
    }

}
  1. Final step add <class name="runners.NewSearchEngineTestRunner" /> in src/test/testng.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite">
    <test verbose="2" preserve-order="true" name="/home/mint/JavaProjects/AutomationFramework/src/test">
        <classes>
            <class name="runners.GoogleTestRunner" />
            <class name="runners.DuckDuckGoTestRunner" />
            <class name="runners.NewSearchEngineTestRunner" />
        </classes>
    </test>
</suite>

About

Test Automation Framework developed using Selenium WebDriver in Java.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published