Skip to content

A Selenium TDD framework that incorporates key features of Selenium and TestNG which can be used to create web-based automation scripts.

Notifications You must be signed in to change notification settings

naveenchr/SeleniumTDD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Selenium TDD Framework

A framework that incorporates key features of Selenium and TestNG which can be used to create web-based automation scripts.

Key Features

  • Supports method wise Parallel test execution
  • Screenshots can be taken for Pass/Fail steps
  • WebDriver manager based browser initiation
  • Platform independent
  • Integration with Extent Reports and Excel result updates
  • Automatic failure reruns
  • Integrated with sonarQube and java code coverage plugin for vulnerability analysis

Note : Utility class is a work in progress

Table of contents

Test Framework Design

image

Test Folder Structure

image

Installation

Clone the repo from GitHub using below command

git clone https://github.com/naveenchr/AutoFrameWork.git

Clean and compile the maven project using below commands

mvn clean
mvn compile

Running the tests

Start test execution from either command prompt or Jenkins

From Command Prompt

mvn clean test -DtestngXML=testng.xml -P Profile_1

Run with groups tag

mvn clean test -DtestngXML=testng.xml -Dgroups="Smoke Test" -P Profile_1

Manual failed run addition to automatic rerun

mvn test -P Profile_2

From Jenkins

mvn clean test -DparallelRun=$parallelMode -DthreadCount=$threadCount -DdataProviderThread=$dataProviderThread -DbrowserType=$browserType -DheadlessMode=$headlessMode -DtestngXML=$testngXML -Dgroups="Smoke Test" -P Profile_1

Report Location

test-output/ExtentReport.html

Sample Report

image

Creating new tests

Test Class File

package com.test.gui;

import java.util.HashMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.annotations.Test;
import com.test.framework.BaseClass;
import com.test.pageobjects.GoogleHomePage;

public class PassFailTest {

	private static final Logger logger = LogManager.getLogger(PassFailTest.class);

	@Test
	public void googleTest_TC001(HashMap<String, String> dataHashMap) {

		try {
			GoogleHomePage googleHomePage = new GoogleHomePage(dataHashMap);
			googleHomePage.searchTextBox();
		} catch (Exception e) {
			BaseClass.getBaseObj().testFailureException(e);
		}
	}

Page Object File

package com.test.pageobjects;

import java.util.Map;
import org.openqa.selenium.By;
import com.test.framework.UtilityClass;

public class GoogleHomePage extends UtilityClass {

	private Map<String, String> map;

	public GoogleHomePage(Map<String, String> map) {
		this.map = map;
	}

	By searchTextBox = By.cssSelector("[type='text']");

	public void searchTextBox() {
		textField(searchTextBox, map.get("From Location"));
	}
}

Excel File

image

Generating sonar and jacoco reports

  • Add sonar server URL in POM file
<sonar.host.url>http://localhost:9000</sonar.host.url>
  • Execute the below maven command after the test run
mvn sonar:sonar

Built With

  • Selenium WebDriver
  • TestNG
  • Maven
  • Git
  • log4j
  • ExtentReport

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the tests as appropriate.

License

MIT

Acknowledgments

References

  • Selenium WebDriver with Java -Basics to Advanced+Frameworks udemy

About

A Selenium TDD framework that incorporates key features of Selenium and TestNG which can be used to create web-based automation scripts.

Topics

Resources

Stars

Watchers

Forks

Languages