Skip to content

A simple automation test examples based on Selenium, TestNG framework with some cool features

License

Notifications You must be signed in to change notification settings

trongtuyen96/automation-test-example

Repository files navigation


background
Automation Test Example

Simple automation test examples based on Selenium, TestNG framework with some cool features

Table of Contents

Sample Test

An example where setting up an chrome driver, run simple test and validate result.

  • Related classes: MyWebDriverManager for setting up web driver
  • SUT: google.com
  • Tests: validate search results

Data Provider Test

Apply dataProvider annotation from TestNG to parameterized input data.

  • Related files/classes: MyWebDriverManager for setting up web driver
  • SUT: calculator.com
  • Tests: validate add calculations, there are 2 tests run with data passing by returned object of @DataProvider annotation

ExcelPOI Test

Data-Driven with data read from Excel file, excel utilities provided.

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • ExcelUtis for reading data from excel files
    • Data.xlsx is excel file test data
  • SUT: calculator.net
  • Tests: validate add calculations, there are 2 tests run with data passing by returned object of @DataProvider annotation

Multi Browser Test

Execute test on multiple browsers, parallel run allowed.

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • MultiBrowser.xml for running on multiple browsers
    • Parallel.xml for running parallelly
  • SUT: automatedtestingiwthtuyen.com
  • Tests: validate current url of page, the browser to run is parameterized by setDriver function

ATWT Page Test

An test with test page (automatedtestingwithtuyen.com) were built following Page Object Model.

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • ATWTHomePage class to define locators and functions
  • SUT: automatedtestingiwthtuyen.com
  • Tests: validate navigation to forum, author pages and search results

ATWT Page Factory Test

An test with test page (automatedtestingwithtuyen.com) were built following Page Factory.

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • ATWTHomePageFactory class to define locators, functions and set up page factory
  • SUT: automatedtestingiwthtuyen.com
  • Tests: validate navigation to forum, author pages and search results

ExtentReport Test

Apply ExtentReport to generate beautiful, fully-detailed, well-organized result report. Fail screenshots captured.

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • extent-config.xml to format extent report
    • report is generated under test-output/ExtentReport_yyyyMMddhhmmss
    • screenshot is located at test-output/screenshots
  • SUT: calculator.net
  • Tests: validate calculation results, failed cases will be captured with screenshots in report

Retry Analyzer Test

Automatically retry to execute failed test cases.

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • RetryAnalyzer with retry count up to 2 times
    • AnnotationTransformer to execute annotations at runtime
    • Retry.xml to run test via execution file
  • SUT: google.com
  • Tests: validate results, the test was forced to fail to check retry feature

Real Time Result Test

Test results are synced in near real time by combination of InfluxDb and Grafana dashboard (with Docker containerized).

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • InfluxDBManager to set up DB connection, DB name and instance
    • InfluxDBListener to write data on test results
    • docker-compose.xml to set up Grafana and InfluxDB containers
    • grafana-datasource.xml to set up datasource for Grafana
    • InfluxDB_Grafana.xml to execute test
  • SUT: github.com
  • Tests: validate overview page, repository page and test results are synced up in Grafana localhost:3000
  • To build containers:
     docker-compose up -d influxdb grafana

Parallel Test With Consolidated Report

Tests are run parallely and one consolidated report is generated for total results.

  • Related files/classes:
    • MyWebDriverManager for setting up web driver
    • ExtentManager to set up Extent report
    • ExtentTestManager to set up methods for logging test on Extent report
    • ParallelTestWithReport.xml to set up parallel runs by test methods
    • Report is located at /test-output
  • SUT: automatedtestingwithtuyen.com
  • Tests: validate patterns page, tools page and frameworks page current urls.

Addition: Dynamically find the suitable web driver (chromedriver, firefoxdriver, etc) against multiple versions in runtime via WebDriverManager.

Author

Tuyen Nguyen - QA Automation Engineer

License

Copyright 2020 Tuyen Nguyen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

About

A simple automation test examples based on Selenium, TestNG framework with some cool features

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages