selenide-testng-reportportal-example

GitHub stars GitHub watchers GitHub forks

Selenide, TestNG, ReportPotal Example

Table of Contents

Environment

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

Frameworks/Libraries

Selenide: 5.17.0 – Web Driver
TestNG: 7.1.0 – Testing Framework
ReportPortal UI: 5.0 – Reporting Engine Service
ReportPortal Java Agent: 5.0.8 – Reporting Engine Agent for TestNG

Project Structure

├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── images
│   └── **/*.png
├── src/test
│   ├── java/com/github/ngoanh2n
│   │   ├── common
│   │   │   ├── BasePage.java
│   │   │   └── BaseTest.java
│   │   ├── components
│   │   │   └── NavigationBar.java
│   │   ├── pages
│   │   │   ├── HomePage.java
│   │   │   └── LoginPage.java
│   │   └── scenarios
│   │       └── ExampleTest.java
│   └── resources
│       ├── log4j.properties
│       ├── reportportal.properties
│       └── selenide.properties
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── docker-compose.yml
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle

How To Use

Clone Repository

$ git clone https://github.com/ngoanh2n/selenide-testng-reportportal-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.

  3. reportportal.properties

    Store information for connecting to ReportPortal web service (Run with Docker in this case).

Deploy ReportPortal With Docker

Install Docker, Docker Machine

Bash completion is a bash function that allows you to auto complete commands or arguments by typing partially commands or arguments, then pressing the [Tab] key. This will help you when writing the bash command in terminal.
$ brew install bash-completion

Docker for Mac is best installed with Homebrew and Homebrew Cask. For other ways to install on MacOS, see Install Docker for Mac in Docker’s docs.
$ brew cask install docker

Download the Docker Machine binary and extract it to your PATH.
$ base=https://github.com/docker/machine/releases/download/v0.16.0 && curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine

To check the version type the following command.

Mac:~ ngoanh2n$ docker --version
Docker version 19.03.5, build 633a0ea

Mac:~ ngoanh2n$ docker-compose --version
docker-compose version 1.25.2, build 698e2846

Mac:~ ngoanh2n$ docker-machine --version
docker-machine version 0.16.0, build 702c267f

Start Docker desktop community.
$ open /Applications/Docker.app

Deploy ReportPortal

By the following official instructions here, you can do that in shortly.

Navigate repository root.
$ cd selenide-testng-reportportal-example

Download the latest compose descriptor.
$ curl https://raw.githubusercontent.com/reportportal/reportportal/master/docker-compose.yml -o docker-compose.yml

Start the application using the following command.
$ docker-compose -p reportportal up -d --force-recreate

Setup ReportPortal UI

Get current IP on your mac machine (For ethernet in this case).

Mac:~ ngoanh2n$ ipconfig getifaddr en0
192.168.1.5

Open your browser with an IP address of the deployed environment at port 8080. In my case: http://192.168.1.5:8080/ui/#login

Use below accounts to access.

default/1q2w3e
superadmin/erebus

Now, I use account superadmin/erebus to create a project named selenide-testng-reportportal-example

Note: If nothing was occured when you logged in, please allocate RAM to 4GB and try again!

Navigate to Projects Management in URL http://192.168.1.5:8080/ui/#administrate/projects

Create a project.

Add a user as ngoanh2n to project selenide-testng-reportportal-example

Now I use account ngoanh2n to join project as role tester.

Copy and replace personal properties into reportportal.properties in resources folder.

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.homePageTest

ReportPortal Results

See test results as launches in URL http://192.168.1.5:8080/ui/#selenide-testng-reportportal-example/launches/all

Visit original content creator repository https://github.com/ngoanh2n/selenide-testng-reportportal-example

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *