Free tools Windows power users keep installed
One-click scans. No signup required.
The import is valid: import org.openqa.selenium.WebDriver;. If Java cannot resolve it, first make sure the Selenium Java library is declared as a dependency of the module and source set containing your file. Then refresh the Maven or Gradle project and run a clean build. Java 11 meets Selenium 4’s documented minimum Java version of 8, so Java 11 alone is not the likely explanation.
Without your build file and full error message, the exact cause cannot be identified. The checks below distinguish a missing or misplaced dependency from an IDE synchronization problem.
As an Amazon Associate I earn from qualifying purchases.
1. Check the import and the file that reports the error
Use Selenium’s fully qualified type name exactly:
import org.openqa.selenium.WebDriver;
For example, this minimal class should compile when the Selenium Java dependency is on the compile classpath:
import org.openqa.selenium.WebDriver;
public class DriverExample {
private WebDriver driver;
}
The import is not a command to install Selenium. It tells the compiler which class the source file uses; the class must also be available through the project’s dependencies. If the import is spelled correctly but the editor reports “cannot resolve symbol” or the compiler reports “package org.openqa.selenium does not exist,” check the dependency and its scope next.
2. Add Selenium to the affected project
Selenium’s Java library is published as org.seleniumhq.selenium:selenium-java. Declare it in the build file for the module that contains the source file. Use a current stable version from Selenium’s Downloads page rather than copying an old version from an unrelated example. Selenium’s Downloads page listed 4.49.0 as stable, released September 9, 2026; versions can change, so verify the current listing when choosing a version.
Rank #2
Maven
Add this dependency inside the project’s <dependencies> element in the relevant module’s pom.xml:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.49.0</version>
</dependency>
The version above is the stable version listed on September 9, 2026, not a timeless recommendation. Check Selenium’s current Downloads page before using it in a new project. If the file is in a Maven submodule, put the dependency in that submodule’s build configuration or ensure the parent configuration actually supplies it to that module.
Gradle
For source code used only by tests, add the dependency to the test source set in the relevant module’s build.gradle:
dependencies {
testImplementation 'org.seleniumhq.selenium:selenium-java:4.49.0'
}
For production source code that directly uses WebDriver, use implementation instead:
Rank #4
dependencies {
implementation 'org.seleniumhq.selenium:selenium-java:4.49.0'
}
As with the Maven example, confirm the version against Selenium’s current Downloads page. A test-only dependency will not make Selenium types available to production source files; choose the configuration that matches where the file lives.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minute3. Refresh the build model, then compile outside the editor
- Save the build file. Verify the dependency is in the module containing the failing source file, not just another module.
- Reload the project in your IDE. Use the IDE’s Maven reload/reimport or Gradle sync action. The exact menu label varies by IDE and version.
- Run a clean build from the project directory. For Maven, run
mvn clean compile. For Gradle, run./gradlew clean build(on Windows, usegradlew.bat clean build). - Compare the result. If the command-line build succeeds but the editor still marks the import as unresolved, investigate IDE synchronization or project configuration. If the command-line build fails too, use its first dependency-resolution or compilation error to guide the next check.
4. Diagnose the failure by its symptom
| What you see | What to check | Next action |
|---|---|---|
| The IDE flags the import, but the command-line build succeeds | The IDE may have a stale or differently configured project model. | Reload or reimport the Maven/Gradle project and confirm the IDE opened the project at the correct root. |
The build says package org.openqa.selenium does not exist |
The dependency may be missing from this module, in the wrong source-set scope, or not resolved. | Check the dependency coordinates and module placement; then inspect the build output for artifact-resolution errors. |
| Tests can see the import but production code cannot | The dependency may be declared only as testImplementation or in a test-only Maven scope. |
Use a production compile scope, such as Gradle implementation, if production sources need Selenium. |
| One module resolves it and another does not | Dependencies are generally associated with a particular project/module and may not be available to a sibling module. | Declare the dependency in the module that compiles the file, or configure a deliberate shared dependency arrangement. |
| The build reports that Selenium artifacts cannot be downloaded or resolved | This is a dependency-resolution problem, distinct from an incorrect import. | Read the repository/network/coordinate error in the build output and correct that resolution issue before troubleshooting the Java import. |
5. Check Java compatibility only after dependency resolution
Selenium’s upgrade guidance states that Selenium 4’s minimum required Java version is 8. Java 11 meets that documented minimum. This does not establish compatibility for every older Selenium release, build plugin, or project configuration; check the actual dependency and build output if the project still fails after Selenium resolves.
Best Value
For Maven, inspect the JDK selected by the IDE and the JDK used by the command-line Maven process. For Gradle, check the project’s configured JDK and the JVM used to run Gradle. A mismatch can cause other build problems, but changing Java versions will not add a missing Selenium dependency to the compile classpath.
Or skip the browser setup
If your goal is to capture a website screenshot rather than build a Selenium-based browser workflow, ScreenshotNeo offers a screenshot API and MCP server. That is an alternative capture method, not a fix for a missing Selenium import. Its one-call request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are not billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for the free plan.
Recommended Free Tools
Frequently Asked Questions
Does importing WebDriver require importing a browser driver class too?
No. The unresolved import in this case is the Selenium API type. Browser and driver setup is a separate step after the project can compile against Selenium.
Can I fix this by downloading a standalone WebDriver executable?
A browser driver executable is not the Selenium Java library dependency. Resolve the Java dependency first; then address browser-driver setup if a later runtime error requires it.
Quick Recap
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.




