GithubHelp home page GithubHelp logo

ngoanh2n / selenide-testng-cucumber-example Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 5.0 2.77 MB

Example project using Selenide, TestNG, Cucumber for Test Automation in Java

Gherkin 15.64% Java 84.36%
test-automation-java selenide testng cucumber cucumber-reports gradle filter-tests java travis-ci

selenide-testng-cucumber-example's Introduction

Twitter Follow GitHub followers GitHub forks GitHub stars GitHub watchers

License: MIT badge-jdk Build Status

Selenide, TestNG, Cucumber Example

Table of Contents generated with DocToc

Environment

Platform: macOS Mojave
IDE: IntelliJ IDEA 2019.3.1 (Community Edition)
Java: 1.8.0_211
Gradle: 6.1.1

Frameworks/Libraries

Selenide: 5.6.1 - Web Driver
TestNG: 7.1.0 - Testing Framework
Cucumber: 5.0.0 - Behavior Driven Development (BDD) Tool
Cucumber Reporting: 0.1.16 - Generating Reports From CucumberTestReport.json For Gradle

Project Structure

├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── images
│   └── **/*.png
├── src/test
│   ├── java/com/github/ngoanh2n
│   │   ├── common
│   │   │   ├── BasePage.java
│   │   │   ├── BaseTest.java
│   │   │   └── ScenarioHooks.java
│   │   ├── pages
│   │   │   ├── HomePage.java
│   │   │   └── LoginPage.java
│   │   ├── scenarios
│   │   │   └── ExampleTest.java
│   │   └── steps
│   │       ├── HomePageStepsDefinition.java
│   │       └── LoginPageStepsDefinition.java
│   └── resources
│       ├── com/github/ngoanh2n/features
│       │   ├── home
│       │   │   ├── welcome-title.feature
│       │   └── login
│       │       ├── login-failure.feature
│       │       └── login-success.feature
│       ├── log4j.properties
│       └── selenide.properties
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle

How To Use

Clone Repository

$ git clone https://github.com/ngoanh2n/selenide-testng-cucumber-example.git

Configuration Files

You can change values for your case.

  1. log4j.properties

    Configuring log4j involves assigning the Level, defining Appender, and specifying Layout objects in a configuration file.

  2. selenide.properties

    Configuration settings for Selenide default browser. Settings can be set either via system property or programmatically.

Run Tests With Gradle

./gradlew clean test

Perform On Browsers

  • chrome
  • firefox
  • ie
  • edge
  • htmlunit
  • phantomjs
  • safari

If run safari, you must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver.

Able to select browser by passing system property selenide.browser

./gradlew clean test -Dselenide.browser=firefox

Filter Tests

You can filter tests by using option --tests
Giving values can be TestPackage, TestClass, TestMethod

./gradlew clean test -Dselenide.browser=firefox --tests ExampleTest

Filter Tags

Choose feature files to run by passing system property cucumber.filter.tags

./gradlew clean test -Dcucumber.filter.tags="TAG_EXPRESSION"

Available tags in project's features:

A tag expression is an infix boolean expression. Below are some examples:

Tag Expression Description Features Filtered
@Client Features tagged with @Client welcome-title,
login-success,
login-failure
@Login or @HomeWelcome Features tagged with either @Login or @HomeWelcome welcome-title,
login-success,
login-failure
@Login and @LoginFailure Features tagged with both @Login and @LoginFailure login-failure
@Client and not @Login Features tagged with @Client that aren’t also tagged with @Login welcome-title

For even more advanced tag expressions you can use parenthesis for clarity, or to change operator precedence:

(@Login or @Home) and (not @LoginFailure) -> welcome-title, login-success

Reports

Cucumber

Note: After test command finished, results are generated at selenide-testng-cucumber-example/build/cucumber-reports

Open file selenide-testng-cucumber-example/build/cucumber-reports/cucumber-pretty/index.html, you can see:

Cucumber Reporting

Note: After test command finished, results are generated by gradle-cucumber-reporting plugin at selenide-testng-cucumber-example/build/cucumber-html-reports

Open file gradle-cucumber-reporting plugin at selenide-testng-cucumber-example/build/cucumber-html-reports/overview-tags.html, you can see:




Test Command Logs


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.