Skip to content

About

AI-augmented UI test automation playbook — Playwright + Cucumber BDD in Java.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

Playwright Automation

Java Playwright Cucumber TestNG Allure Datafaker Jenkins Maven License

Overview

This repository contains an automated end-to-end test suite built with Playwright and Cucumber, executed via a TestNG runner. The framework is designed around configurability, maintainability, and clear, evidence-backed reporting.

Two feature areas are currently covered:

  • Contact Us form — successful submission, validation error handling.
  • Login Portal — native JS alert verification for valid and invalid credentials.

Key capabilities:

  • Cross-browser execution — Chromium and Firefox, selectable at runtime.
  • Externalized configuration — browser, base URL, headless mode, and timing are driven entirely from a properties file and may be overridden via JVM system properties.
  • Dependency injection — step definition and hook classes are wired together via Cucumber's PicoContainer integration, avoiding static shared state between scenarios.
  • Tag-based scenario selection — scenarios are tagged (@contact-us, @login, @smoke, @demo-failure) so runs can be filtered to a subset without editing feature files.
  • Allure reporting — every scenario is reported with a full step timeline; failed scenarios automatically capture and attach a screenshot of the application state at the point of failure.
  • Randomized test data — the successful-submission scenario uses Datafaker to generate random names, emails, and messages at runtime, rather than relying on hardcoded values.
  • Continuous integration — a Jenkins pipeline (see Jenkinsfile) builds the project, runs the suite headless, publishes a Test Result Trend graph, and archives the Allure report as a build artifact.

Configuration

All environment values are defined in src/test/resources/config/config.properties:

Key Description
browser Target browser (chromium or firefox)
base.url Base URL of the application under test
headless Whether to run headless (true/false)
step.delay.ms Pause applied after each Gherkin step
login.portal.path Path appended to base.url for the Login Portal page

Any key may be overridden at runtime via a JVM system property without modifying the properties file, for example:

java -Dbrowser=firefox -cp "$CP" org.testng.TestNG -testclass runner.TestRunner

Running the Suite

mvn dependency:build-classpath -Dmdep.outputFile=/tmp/cp.txt -q
CP=$(cat /tmp/cp.txt):target/classes:target/test-classes
java -cp "$CP" org.testng.TestNG -testclass runner.TestRunner

To run a specific subset of scenarios, override the tag filter at runtime:

java -Dcucumber.filter.tags="@login" -cp "$CP" org.testng.TestNG -testclass runner.TestRunner

Continuous Integration

The Jenkinsfile defines a declarative pipeline with two build parameters:

Parameter Description
BROWSER chromium or firefox
CUCUMBER_TAGS Cucumber tag expression to filter scenarios for that run

The pipeline checks out the repo, builds it, runs the suite headless, publishes JUnit-format test results (for the build's Test Result Trend graph), generates the Allure report, and archives both the Allure results and report as build artifacts.

A Jenkins pipeline job (playwright-cucumber-automation) is already configured against this repository, pulling main and executing Jenkinsfile directly — no additional Jenkins-side scripting is needed. To reproduce this setup on another Jenkins instance:

  1. Install the TestNG Results plugin (required for the junit/TestNG report publishing step to have a matching test framework on the classpath).
  2. Create a new Pipeline job.
  3. Under Pipeline, choose Pipeline script from SCM, set the SCM to Git, point it at this repository's URL and the main branch, and set the script path to Jenkinsfile.
  4. Run the job once — this registers the BROWSER and CUCUMBER_TAGS parameters (declared inside the Jenkinsfile itself) so subsequent runs can be triggered with Build with Parameters.

Reporting

Generate and view the Allure report:

mvn io.qameta.allure:allure-maven:2.12.0:serve

When a scenario fails, a screenshot of the current page state is automatically captured and attached to that scenario's entry in the report (see Hooks.java/BrowserManager.java), providing immediate visual context for the failure without needing to re-run the test.

Sample Report — Failed Scenario

Failed scenario in Allure report

License

This project is licensed under the MIT License.

About

AI-augmented UI test automation playbook — Playwright + Cucumber BDD in Java.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages