Coder Social home page Coder Social logo

rumy14 / seleniumtdd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from naveenchr/seleniumtdd

0.0 0.0 0.0 54 KB

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

Java 100.00%

seleniumtdd's Introduction

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

seleniumtdd's People

Contributors

naveenchr avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.