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.
- 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.
- 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
- Java 8 or above installed
- Maven or Gradle build tool
- Recommended: Latest version of Node.js
- Clone the repository:
git clone https://github.com/krishnaharshap/Playwright-Java.git cd Playwright-Java - Install dependencies:
For Maven:
mvn installFor Gradle:
gradle build- Install Playwright Browsers:
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install"mvn testor use your preferred build tool command.
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();
}
}
}Playwright-Java/
├── src/
│ ├── main/java/ # Core framework and utilities
│ └── test/java/ # Test cases and page objects
├── pom.xml / build.gradle
└── README.md
Contributions, issues, and feature requests are welcome!
Feel free to check issues page.
Krishna Harsha
GitHub