Create a Maven Java project in Eclipse, add TestNG and Selenium as dependencies, then run a TestNG test from the IDE or with Maven. For current Selenium releases, you can usually start without downloading a browser driver manually: Selenium Manager can find and cache one when needed. This guide walks through both setup paths and the issues most likely to stop a first test from running.
What you need before you begin
- Eclipse with Maven integration. The steps below use a Maven project so dependencies and versions are recorded in
pom.xml. - A Java installation supported by the releases you choose. The TestNG Eclipse plugin documentation specifies Eclipse 4.2 or newer, and Java 11 or newer for plugin 7.8.0 and later; those are plugin requirements, not a compatibility guarantee for every Selenium and TestNG release combination. See TestNG’s Eclipse plugin documentation.
- A supported browser installed on the machine where the test will run.
TestNG supplies test annotations and execution; Selenium WebDriver controls the browser. Installing the Eclipse plugin does not add the TestNG runtime library to your project.
Create a Maven project in Eclipse
- In Eclipse, choose File → New → Maven Project. If the wizard is not available, check that Eclipse’s Maven integration is installed.
- Choose a workspace location and, if offered, a simple project archetype. Enter a group ID and artifact ID, then finish the wizard.
- Confirm the project has a
pom.xmland a test source directory, usuallysrc/test/java. If Eclipse has not recognized it as a Maven project, right-click the project and choose Configure → Convert to Maven Project where available.
Maven keeps the dependency declarations with the project, making it easier to run the same test setup outside Eclipse. TestNG’s Maven guidance recommends integrating with Surefire: TestNG with Maven. Selenium also documents adding its Java library with a build tool: Selenium Java library installation.
Add TestNG and Selenium dependencies
Add TestNG with test scope and Selenium’s Java library to the project’s pom.xml. Versions change, so check the official release and installation pages and choose versions compatible with your installed Java runtime rather than copying an old tutorial’s numbers. TestNG’s Maven page has a dependency example; Selenium’s Java page directs readers to its current downloads information.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>YOUR_TESTNG_VERSION</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>YOUR_SELENIUM_VERSION</version>
</dependency>
</dependencies>
Replace both version values with actual compatible releases before saving. In Eclipse, save the file and allow Maven to update the project. If dependencies do not appear, right-click the project and choose Maven → Update Project.
Install the TestNG plugin for Eclipse
The plugin adds IDE features such as a TestNG test wizard, launch configurations and a results view. It is useful for authoring and running tests in Eclipse, but the Maven dependency above is still required for the project itself.
- Open Help → Eclipse Marketplace, search for TestNG, and install the TestNG plugin; or choose Help → Install New Software and use the official update site:
https://testng.org/testng-eclipse-update-site. - Complete the installation and restart Eclipse when prompted.
- Verify that TestNG actions are available, for example by opening File → New and checking for the TestNG test wizard.
The TestNG project describes the plugin as a way to run tests from Eclipse and monitor execution and output. See the plugin documentation for its current installation and launch options.
Rank #2
Write a browser test
Create a Java class under src/test/java, using a package that matches your project structure. This minimal example opens a public page, checks its title, and quits the browser even if the assertion fails:
package example;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class HomePageTest {
@Test
public void pageHasExpectedTitle() {
WebDriver driver = new ChromeDriver();
try {
driver.get("https://example.com");
Assert.assertTrue(driver.getTitle().contains("Example Domain"));
} finally {
driver.quit();
}
}
}
Use a URL and assertion appropriate to the site you are testing. driver.get navigates to the page; Selenium’s locators can then find elements for interaction and assertions. The finally block calls quit() to end the WebDriver session and close its browser windows. Selenium’s first-script guide shows the basic browser-session pattern: Selenium first script.
Run the test from Eclipse or Maven
Run a class or method in Eclipse
- Right-click
HomePageTest.javain the Package Explorer. - Choose Run As → TestNG Test.
- Review the TestNG results view and Eclipse’s Console for the run status, failures and error details.
The TestNG plugin also supports launch configurations for a class, group, XML suite or individual method. Use Run → Run Configurations when you need to choose a specific target or configure the launch.
Run through Maven
From the project directory, run:
mvn test
This uses the project’s Maven test configuration, including Surefire when it is configured for TestNG. It is a useful check that the test can run through the build path rather than only through an IDE launch. Eclipse and Maven runs can differ if their suite XML, JVM properties, environment variables or plugin configuration are not aligned.
Do you need to download a browser driver?
WebDriver needs a browser and a matching driver component. With modern Selenium releases, start by letting Selenium Manager handle a missing driver: it is included with Selenium and can be invoked by the bindings to discover, download and cache drivers. In the example, new ChromeDriver() is the normal starting point; a separate manual driver download is not always necessary.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →This depends on Selenium Manager being able to access the information and downloads it needs, and on a compatible browser being available. In restricted networks, or when a team must pin a specific driver, configure the driver explicitly or provide it on PATH according to the Selenium documentation: Selenium Manager.
Rank #4
Troubleshoot common setup failures
Eclipse cannot find TestNG annotations or imports
Installing the Eclipse plugin alone does not add TestNG to the Maven project. Confirm that the TestNG dependency is in pom.xml, then update the Maven project and check that dependency resolution completed.
The test class does not appear or run
Place the class under src/test/java, confirm it contains a method annotated with @Test, and verify there are no compilation errors. If using an XML suite, check that the class or package is included in that suite.
ChromeDriver or another driver fails to start
Confirm the browser is installed and supported by the Selenium release. Check the exception text and network access if Selenium Manager cannot resolve or download a driver. In a controlled environment, configure a known driver through the appropriate Selenium Service or PATH setup rather than relying on automatic discovery.
Recommended Free Tools
Best Value
The Java version or dependencies are rejected
Check the Java runtime Eclipse uses as well as the one Maven uses in the terminal; they may differ. Select Selenium and TestNG versions supported by that runtime. The TestNG plugin’s Java 11+ requirement for versions 7.8.0 and newer does not establish the full compatibility matrix for the project libraries.
Eclipse passes but mvn test fails, or vice versa
Compare the selected test class or suite, Maven Surefire settings, system properties and environment variables. An IDE launch can use Eclipse-specific runtime settings, while Maven uses the build configuration in the project.
Or skip the browser setup
If you need a screenshot of a webpage rather than an interactive Selenium test, ScreenshotNeo can return an image or PDF with one API request. It is not a replacement for Selenium when a test must interact with a browser, click controls or verify application behavior.
Quick Recap
For example, with cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for options and response details. It removes cookie banners, newsletter popups and chat widgets before capture; bot checks, blank pages and failed loads are not billed. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




