Last updated on October 6th, 2025 at 03:04 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?
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.

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.

Hi, I’m Aravind — a seasoned Automation Test Engineer with over 17 years of hands-on experience in the software testing industry. I specialize in tech troubleshooting and tools like Selenium, Playwright, Appium, JMeter, and Excel automation. Through this blog, I share practical tutorials, expert tips, and real-world insights to help testers and developers improve their automation skills.In addition to software testing, I also explore tech trends and user-focused topics, including Snapchat guides, codeless test automation, and more.