Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use Selenium with IntelliJ IDEA, create a Java project, add Selenium through Maven or Gradle, write a test with JUnit or TestNG, and run it from the IDE. Selenium sends commands to a browser through WebDriver; IntelliJ helps you edit, run, and debug the test, but it is not itself the browser or its driver.

What you need before you start

  • A Java Development Kit (JDK) that is suitable for your project and selected in IntelliJ IDEA.
  • A supported browser installed in the environment where the test will run.
  • A build tool such as Maven or Gradle to manage Selenium and test-framework dependencies.
  • A test framework, commonly JUnit or TestNG, if you want IntelliJ to discover and run tests as tests.

WebDriver is the browser-control interface. Selenium’s Java binding provides the Java API, while a browser-specific driver implementation connects that API to the browser. Keep those pieces distinct when diagnosing setup failures. Selenium can resolve browser drivers for supported configurations, but the exact behavior depends on current Selenium, browser, driver, and environment versions.

Create a Selenium project in IntelliJ IDEA

  1. Open File | New | Project.
  2. Select Selenium, choose Java, then choose Maven or Gradle.
  3. Select JUnit or TestNG, and select or download a JDK.
  4. Follow the wizard prompts for the Selenium version and dependencies, then finish creating the project.
  5. Allow IntelliJ to load and sync the build project. If the project was created without the wizard, add Selenium to the correct module’s build file and reimport it.

JetBrains’ IntelliJ IDEA 2026.2 Help states: “Selenium support in IntelliJ IDEA is provided by the Test Automation plugin, and most of the features described in this section rely on it.” The Test Automation plugin supplies most Selenium-specific IDE features; basic test running and debugging can work without it.

Add Selenium to a Maven project

For an existing Java project, add the Selenium Java binding to that project’s pom.xml. The following uses Selenium 4.49.0 and Java source/target 17 because those are the values in Selenium’s Java installation example; they are documentation-example values, not a universal minimum or a recommendation for every project. Check the current Selenium compatibility requirements and your project’s Java constraints before selecting versions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
<properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <selenium.version>4.49.0</selenium.version>
    <junit.version>5.11.4</junit.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

After saving the file, open the Maven tool window and use its reload action, or accept IntelliJ’s prompt to load Maven changes. Confirm that the project has finished syncing before trying to import Selenium classes. In Maven projects, the Java compiler version set in pom.xml takes precedence over the JDK used by the Maven importer in IntelliJ’s settings; align both deliberately.

If you are using Gradle instead, add the Selenium Java binding and your chosen test framework to the project’s Gradle dependencies, then sync Gradle. Follow the repository’s existing build conventions rather than introducing a second build tool.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Write and run a first JUnit test

Create a test class under the project’s test source directory, usually src/test/java. This example opens Selenium’s sample web form, checks its page title, and closes the browser even if an assertion fails.

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import static org.junit.jupiter.api.Assertions.assertEquals;

class FirstSeleniumTest {
    private WebDriver driver;

    @BeforeEach
    void setUp() {
        driver = new ChromeDriver();
    }

    @Test
    void opensSeleniumSamplePage() {
        driver.get("https://www.selenium.dev/selenium/web/web-form.html");
        assertEquals("Web form", driver.getTitle());
    }

    @AfterEach
    void tearDown() {
        if (driver != null) {
            driver.quit();
        }
    }
}

On an initial run, driver setup may take extra time while Selenium downloads and verifies a needed driver. Run the test using the green gutter icon beside the test class or method, or put the caret in the test and use IntelliJ’s run action. Output and failures appear in the Run/Test Runner window. To debug, set a breakpoint and launch the test in Debug mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Use quit() at the end of a session so the browser and driver process are released. A new driver per test is a straightforward way to keep browser sessions isolated while learning; larger suites may use a deliberate fixture or test lifecycle strategy.

Choose Maven or Gradle, JUnit or TestNG

Choice What to weigh Practical approach
Maven or Gradle Repository convention, dependency setup, team familiarity, and CI build Use the build tool already used by the project. IntelliJ’s Selenium wizard supports both.
JUnit or TestNG Team familiarity and required test features Use the framework already established by the project unless a concrete need points elsewhere. Selenium describes JUnit as widely used for Java Selenium tests and notes TestNG’s parallel-execution and parameterized-test features.
IDE run or Maven run Interactive authoring and debugging versus command-line build consistency Use IntelliJ for focused development, then also run the test through the project’s build tool to check the command-line path used by CI.

Wait for page conditions instead of fixed sleeps

Page loading and asynchronous UI changes do not always finish at the same time. Avoid using arbitrary fixed sleeps as the normal readiness strategy: they can make a test slower when the page is ready early and flaky when it is not ready by the end of the delay. For production tests, use Selenium waits tied to a meaningful condition, such as an element becoming visible or clickable. Keep the condition specific to the page behavior being tested.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Run the test from Maven as well

IntelliJ can delegate Maven-based tests to Maven, and a command-line run is useful for checking that the test does not depend on IDE-only configuration. From the project directory, run:

mvn test

If the IDE can run the test but Maven cannot, inspect the Maven output and verify that the dependency, test framework, and compiler settings are in the Maven project rather than only in an IDE configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Troubleshoot common IntelliJ and Selenium problems

Selenium imports are unresolved

  • Likely cause: The dependency is absent, was added to a different module, or the build project has not synced.
  • Fix: Check that org.seleniumhq.selenium:selenium-java is in the correct Maven or Gradle module, then reload Maven or sync Gradle. Wait for dependency resolution to finish and inspect the build tool window for errors.

IntelliJ does not recognize or run the test

  • Likely cause: The test framework dependency is missing, the class is outside the test source set, or the project JDK is not configured as intended.
  • Fix: Verify the JUnit or TestNG dependency, test-source location, and selected JDK. Try the gutter Run control and inspect the Run/Test Runner output for the underlying compile or discovery error.

The browser does not start

  • Likely cause: The browser is missing, a driver cannot be resolved, or the browser, driver, Selenium, and operating environment are incompatible.
  • Fix: Confirm the browser is installed and available to the test process. Check current Selenium and browser-vendor documentation for the specific versions and environment, then inspect the exception for driver-resolution or startup details. Driver support and resolution behavior can change over time.

The test passes in IntelliJ but fails in the build

  • Likely cause: The IDE and build tool may be using different Java settings, dependencies, or test execution configurations.
  • Fix: Compare the JDK selected in IntelliJ with the compiler level in pom.xml, then run the build from the project directory and use its output to identify the mismatch.

The test is flaky or leaves browser processes open

  • Likely cause: The test proceeds before the relevant page condition is true, or a browser session is not closed after failure.
  • Fix: Wait for a meaningful page condition and ensure teardown calls driver.quit(), including after assertion failures.

Or skip the browser setup

If the task is to capture a website screenshot rather than interact with and assert on a browser workflow, ScreenshotNeo is a screenshot API and MCP server; it does not replace Selenium for browser automation tests. One GET request can return a screenshot or PDF. For example:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://www.selenium.dev/selenium/web/web-form.html -o shot.webp

See the ScreenshotNeo documentation for API parameters. It accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Can I use Selenium with IntelliJ IDEA Community Edition?

The documented setup is a Java project with a build tool and test framework; plugin availability and Selenium-specific IDE features can depend on the IntelliJ edition and installed plugins. Check the current IntelliJ IDEA documentation for the edition you use.

Do I need to install ChromeDriver manually?

Not necessarily. Selenium can resolve drivers for supported setups, but the exact resolution behavior depends on the versions and environment. If startup fails, check current Selenium and browser-vendor guidance for your configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.