Last updated on November 8th, 2025 at 10:35 am
If you are working with Playwright for Java, you might wonder how to run Playwright test using JUnit in Eclipse IDE. The process is simple once you configure your project correctly. With JUnit 5 support, you can write automated browser tests in Java and execute them directly inside Eclipse. In this guide, we will cover the complete setup and provide a working example.
- What is Playwright?
- Prerequisites
- Step 1: Create a Maven Project
- Step 2: Add Playwright and JUnit Dependencies
- Step 3: Write Your First Playwright Test with JUnit
- Step 4: Run the Test in Eclipse IDE
- What's Next
- Conclusion
What is Playwright?
Playwright is an open-source test automation framework created by Microsoft. It allows you to test web applications across Chromium, Firefox, and WebKit using a single API. With Playwright for Java, you can integrate automated tests into your existing Java projects and run them using JUnit.
Prerequisites
Before you begin, make sure you have:
- Eclipse IDE for Java Developers installed. (Download from the official website)
- Java 11 or higher. (Download from the official website)
- Maven is installed and configured in Eclipse. (Download from the official website)
If you are new, check this step-by-step guide on how to install and set up Playwright in Eclipse with Maven.
Step 1: Create a Maven Project
- Open Eclipse and go to File > New > Maven Project.
- Select Create a simple project (skip archetype selection)
- Provide groupId (e.g., com.example) and artifactId (e.g., playwright-tests).
- Click the Finish button
It will create a Maven project with a pom.xml file in the Eclipse IDE.
Step 2: Add Playwright and JUnit Dependencies
To run Playwright tests with JUnit, we need to add Playwright and JUnit dependencies in the POM.xml file. Open your project’s pom.xml and add the following dependencies to it:
<dependencies>
<!-- Playwright Java -->
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.55.0</version>
</dependency>
<!-- JUnit 5 -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>After adding, right-click the project and select Maven > Update Project. It will download the Playwright and JUnit libraries (JAR files) from the Maven repository and add them to your project’s classpath automatically so you can use them in your code.
Step 3: Write Your First Playwright Test with JUnit
Create a test class inside src/test/java named GoogleTest.java with the package name com.example.test. Paste the provided test script into it.
package com.example.test;
import com.microsoft.playwright.*;
import org.junit.jupiter.api.*;
public class GoogleTest {
static Playwright playwright;
static Browser browser;
@BeforeAll
static void setUp() {
playwright = Playwright.create();
browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false));
}
@AfterAll
static void tearDown() {
browser.close();
playwright.close();
}
@Test
void testGoogleTitle() {
Page page = browser.newPage();
page.navigate("https://www.google.com");
String title = page.title();
Assertions.assertEquals("Google", title);
page.close();
}
}This test launches Chromium, opens Google, and verifies the page title.
Step 4: Run the Test in Eclipse IDE
- Right-click on the test class.
- Select Run As > JUnit Test.

- The test will execute, and the results appear in the JUnit panel.

What’s Next
Now that you’ve learned how to run Playwright tests using JUnit in Eclipse IDE, you can deepen your understanding by exploring our detailed guide on Playwright with TestNG test automation. This guide covers advanced setup, test structuring, and best practices to help you build robust automated test suites efficiently.
Conclusion
Now you know how to run Playwright test using JUnit in Eclipse IDE. By setting up a Maven project, adding dependencies, and writing a simple test, you can automate browser actions directly inside Eclipse. With JUnit 5 integration, your Playwright tests become part of your standard Java testing workflow.




