Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BDD framework for automation using Selenium Cucumber and TestNg

License

NotificationsYou must be signed in to change notification settings

rahulrathore44/SeleniumCucumber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BDD framework for automation using Selenium Cucumber and TestNg

The framework has following features

  1. Modular Design
  2. Maven based framework
  3. Log4j enabled for logging
  4. Report Generation (cucumber-reporting)
  5. Helper class to handle web component such as (Button,Link etc)
  6. Centralized Configuration (Using Properties file)
  7. POM
  8. Hooks for different browser support (using tag @chrome,@firefox...)

YouTube Playlist

Here is the basic code:

To use the class for handling the web component create the object and use it

GridHelpergrid =newGridHelper(driver);grid.typeInGrid(item,GridLocator.cartId,1,1,qty);

Add the Feature file

Add the feature file undertest\resources\featurefile

Feature:AddingalaptoptotheCart@chromeScenario:SearchLaptopandaddittothecartGiven :IamatthehomepageWhen :Iclickonthe "Laptops"searchfilterThen :Ishouldbeatthe "Laptops"searchpagewith "35items"And :Thetitleshouldbe "Laptops"searchpageThen :Iselectthe"APPLE MacBook Pro Retina"withdescriptionas"15-inch, 256GB"And :AddittothecartThen :Navigatetouserdetailspageandprovidethefollowingdetails      |Destination |Singapore  |      |Airline     |AirAsia    |      |FlightNo    |A089       |      |FlightDate  |24/08/2016 |      |FlightTime  |5:00       |      |Terminal    |Terminal1 |      |FirstName   |Selenium   |      |LastName    |Java       |      |Email       |sq@j.com   |      |Phone       |121212121 |

use the tag@chrome to launch the specific browser or no-tag to use the browser form theconfig.properties file

Create the Runner

/** * @author rahul.rathore * *14-Aug-2016 */packagecom.cucumber.framework.runner;importcucumber.api.CucumberOptions;importcucumber.api.testng.AbstractTestNGCucumberTests;@CucumberOptions(features = {"classpath:featurefile/Search.feature" },glue = {"classpath:com.cucumber.framework.stepdefinition","classpath:com.cucumber.framework.helper" },plugin = {"pretty","json:target/SearchFeatureRunner.json" })publicclassSearchFeatureRunnerextendsAbstractTestNGCucumberTests {}

Use the testng.xml file to run the test cases

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPEsuite SYSTEM "http://testng.org/testng-1.0.dtd"><suitename="Suite"><listeners><listenerclass-name="com.cucumber.framework.listeners.reportlistener.CucumberReport" /></listeners><testname="Test - 1"><classes><classname="com.cucumber.framework.runner.SearchFeatureRunner" /><classname="com.cucumber.framework.runner.LaptopFeatureRunner" /><classname="com.cucumber.framework.runner.TabletFeatureRunner" /><classname="com.cucumber.framework.runner.SearchWithFilterRunner" /></classes></test></suite>

To see this whole thing running simply checkout this project and run this command:

mvn clean generate-sources test

Cucumber Report

There is a feature overview page:

feature overview page

And there are also feature specific results pages:

feature specific page passing

And useful information for failures:

feature specific page passing

If you have tags in your cucumber features you can see a tag overview:

Tag overview

And you can drill down into tag specific reports:

Tag report

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp