Getting Started

Set up the Playwright Java Framework and run your first test in minutes.

Prerequisites

Before you begin, ensure you have the following installed:

  • Java 17 or higher - Check your version with java -version
  • Maven 3.8 or higher - Check your version with mvn -version
Note
Node.js is NOT required. Playwright Java manages browsers itself, so you don't need to install Node.js or npm.

Installation

1. Clone the Repository

git clone https://github.com/kamrankhan54/playwright-java-framework.git
cd playwright-java-framework

2. Install Project Dependencies

Install all Maven dependencies:

mvn clean install

This will download all required dependencies including Playwright for Java, Cucumber, JUnit 5, and Jackson for JSON parsing.

3. Install Playwright Browsers

Install Playwright browsers using Maven:

mvn exec:java \
  -Dexec.mainClass="com.microsoft.playwright.CLI" \
  -Dexec.args="install --with-deps"

This command installs Chromium, Firefox, and WebKit browsers along with their system dependencies.

Environment Variables

The framework uses environment variables for authentication and API testing. Set them before running tests:

macOS / Linux

export DOMTREE_USER="your-email"
export DOMTREE_PASS="your-password"
export DOMTREE_API_BASE="https://api.domtree.com"

Windows (PowerShell)

setx DOMTREE_USER "your-email"
setx DOMTREE_PASS "your-password"
setx DOMTREE_API_BASE "https://api.domtree.com"
Important
After setting environment variables in PowerShell, you may need to restart your terminal or IDE for the changes to take effect.

Project Structure

After installation, your project structure should look like this:

src/
 ├─ test/
 │   ├─ resources/
 │   │   └─ features/
 │   │        └─ example.feature
 │   └─ java/
 │       ├─ steps/
 │       │   └─ LoginSteps.java
 │       ├─ api/
 │       │   └─ ApiClient.java
 │       └─ support/
 │           └─ TestContext.java
playwright.config
pom.xml
README.md

Running Your First Test

Run the full test suite:

mvn test

Or run a specific feature file:

mvn test -Dcucumber.features="src/test/resources/features/login.feature"

Next Steps