Skip to content

krishnaharshap/Playwright-Java

 
 

Repository files navigation

Playwright-Java

Playwright-Java is a sample automation framework demonstrating how to use Playwright with Java for end-to-end web application testing. This repository provides example code and structure to help you quickly get started with automating browser tests using Playwright’s powerful and reliable automation capabilities in the Java ecosystem.


🚀 Main Purpose

  • Browser Automation: Automate web applications across Chromium, Firefox, and WebKit browsers.
  • End-to-End Testing: Write, organize, and execute comprehensive UI tests for your web projects.
  • Java Integration: Leverage Playwright’s capabilities directly from Java, enabling seamless integration with existing Java test suites and build tools.

📦 Features

  • Cross-browser support (Chrome, Firefox, Safari/WebKit)
  • Fast execution with reliable automation
  • Simple, readable Java code and structure
  • Example test cases and page object models
  • Easy integration with CI/CD pipelines

🛠️ Getting Started

Prerequisites

  • Java 8 or above installed
  • Maven or Gradle build tool
  • Recommended: Latest version of Node.js

Installation

  1. Clone the repository:
    git clone https://github.com/krishnaharshap/Playwright-Java.git
    cd Playwright-Java
  2. Install dependencies:

For Maven:

  mvn install

For Gradle:

gradle build
  1. Install Playwright Browsers:
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install"

Running Tests

mvn test

or use your preferred build tool command.

✨ Example Usage

import com.microsoft.playwright.*;

public class ExampleTest {
    public static void main(String[] args) {
        try (Playwright playwright = Playwright.create()) {
            Browser browser = playwright.chromium().launch();
            Page page = browser.newPage();
            page.navigate("https://example.com");
            System.out.println(page.title());
            browser.close();
        }
    }
}

📁 Project Structure

Playwright-Java/
├── src/
│   ├── main/java/       # Core framework and utilities
│   └── test/java/       # Test cases and page objects
├── pom.xml / build.gradle
└── README.md

📝 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to check issues page.


📚 Resources


🧑‍💻 Author

Krishna Harsha
GitHub

About

PlaywrightWithJavaCodes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%