Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk10 min

How to Build a Hybrid Framework in Selenium: A Practical Java Guide

A practical Java and JUnit pattern for combining data-driven Selenium tests with Page Objects, reliable waits, clean browser lifecycle management, and optional Grid execution.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A maintainable Selenium “hybrid framework” is not a Selenium-prescribed product or architecture. Here, it means a Java test setup that combines data-driven test cases with Page Objects, JUnit for execution and assertions, and a small support layer for browser setup and waits. WebDriver controls the browser; JUnit owns test execution and assertions; Page Objects keep UI-specific operations out of test intent. Start with one local browser, make readiness checks explicit, then add Selenium Grid when remote or parallel execution is useful.

What “hybrid framework” means in this guide

Selenium’s official documentation does not define a canonical hybrid framework or require a particular combination of patterns. “Hybrid” can mean different things across teams: data-driven tests, keyword-driven steps, behavior-driven specifications, or a mix. This guide uses a concrete, deliberately limited definition: Java + JUnit, data supplied to parameterized test cases, Page Objects for UI operations, and a support layer for configuration and WebDriver lifecycle. It does not add a separate keyword language or a behavior-driven layer; those are optional choices, not requirements for a Selenium framework.

This separation follows Selenium’s documented division of responsibilities: “WebDriver has one job and one job only: communicate with the browser via any of the methods above.” Selenium explains where frameworks fit; test runners provide test execution and assertions, which WebDriver does not.

Choose the runner and define the responsibilities

Use a test runner that fits the language binding and your team’s CI/reporting needs. Selenium lists JUnit and TestNG for Java, pytest and unittest for Python, NUnit and MSTest for .NET, and Jest and Mocha for JavaScript. TestNG may suit teams that need its documented parameterization and parallel features; JUnit is a straightforward choice for this Java example. Add a BDD layer such as Cucumber only if readable Given/When/Then scenarios solve a real collaboration need.

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.
Layer Owns Should not become
Test Scenario intent, input data, assertions, and test outcome A pile of browser locators and low-level click sequences
Page or component object Locators and meaningful operations on a page or reusable UI component A general-purpose assertion engine or test runner
Support Configuration, browser session creation and cleanup, shared wait conventions Business-specific test behavior
Data layer Inputs for parameterized scenarios and, where appropriate, expected values Opaque data that hides what a test is verifying

Selenium’s Page Object guidance recommends public page services and localized UI details. Its documentation says, “This reduces the amount of duplicated code and means that if the UI changes, the fix needs only to be applied in one place.” Page objects generally should not make assertions or expose their internal locators as the test’s main interface.

Set up a small, maintainable project

A conceptual layout might be:

src/test/java/example/tests/      # test intent and assertions
src/test/java/example/pages/      # page and component objects
src/test/java/example/support/    # driver lifecycle, config, wait conventions
src/test/resources/               # test data or configuration

This is an example, not a Selenium-mandated folder layout. Keep the number of abstractions proportional to the suite: a small test suite may need only a test class, a page object, and a lifecycle fixture.

Declare dependencies deliberately

Selenium’s current Java installation example uses Selenium 4.49.0 with JUnit 6.1.3. Those are documentation examples, not a universal compatibility guarantee. Confirm Java runtime, Selenium binding, test-runner, browser, and CI compatibility together before pinning versions. Here is a minimal Maven dependency example using those documented example versions:

<properties>
  <maven.compiler.release>17</maven.compiler.release>
  <selenium.version>4.49.0</selenium.version>
  <junit.version>6.1.3</junit.version>
</properties>
<dependencies>
  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>${selenium.version}</version>
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>${junit.version}</version>
    <scope>test</scope>
  </dependency>
</dependencies>

Configure a Maven Surefire version and Java toolchain compatible with your environment in the build; the values are project decisions rather than Selenium requirements. Selenium’s installation guide covers its language bindings and dependency installation.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Implement the browser lifecycle and page object

Keep driver creation and cleanup in a fixture rather than repeating them in every test. Selenium Manager ships with Selenium releases and can manage drivers when one is not supplied. A local example follows. It uses the first-party Selenium API, JUnit lifecycle methods, and explicit waits.

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.

Driver setup

package example.support;

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

public abstract class WebTest {
    protected WebDriver driver;

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

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

For larger suites, put browser selection and remote/local choice behind a small factory or configuration setting. Avoid building a large framework layer before you need multiple browsers or execution environments. Selenium Manager may need access to driver/browser version endpoints to obtain a driver; corporate proxies, restricted networks, or platform limitations can affect that. Selenium documents Linux ARM/aarch64 limitations, so verify support for the actual runner architecture.

Page object

This example page object represents a hypothetical sign-in page. Replace the URL, selectors, and success condition with the application’s real contract.

package example.pages;

import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class SignInPage {
    private final WebDriver driver;
    private final WebDriverWait wait;
    private final By email = By.id("email");
    private final By password = By.id("password");
    private final By submit = By.cssSelector("button[type='submit']");
    private final By accountHeading = By.cssSelector("[data-testid='account-heading']");

    public SignInPage(WebDriver driver) {
        this.driver = driver;
        this.wait = new WebDriverWait(driver, Duration.ofSeconds(10));
    }

    public SignInPage open(String baseUrl) {
        driver.get(baseUrl + "/signin");
        wait.until(ExpectedConditions.visibilityOfElementLocated(email));
        return this;
    }

    public SignInPage enterCredentials(String userEmail, String userPassword) {
        wait.until(ExpectedConditions.visibilityOfElementLocated(email)).sendKeys(userEmail);
        driver.findElement(password).sendKeys(userPassword);
        return this;
    }

    public void submit() {
        wait.until(ExpectedConditions.elementToBeClickable(submit)).click();
    }

    public String accountHeadingText() {
        return wait.until(ExpectedConditions.visibilityOfElementLocated(accountHeading)).getText();
    }
}

The page object exposes user-meaningful operations and a value the test can assert. The assertion remains in the test. Prefer stable application-owned selectors, such as test IDs where available, over brittle positional or styling selectors.

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

Write data-driven tests without hiding intent

Parameterization is the data-driven part of this example. Each input row should correspond to a case whose expected outcome is understandable. Keep secrets out of source control; retrieve credentials from the CI secret store or another approved secret mechanism.

package example.tests;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import example.pages.SignInPage;
import example.support.WebTest;

class SignInTest extends WebTest {
    static Stream<Arguments> validUsers() {
        return Stream.of(
            Arguments.of("[email protected]", "example-password", "Welcome, Alice")
        );
    }

    @ParameterizedTest
    @MethodSource("validUsers")
    void validUserCanOpenAccount(String email, String password, String expectedHeading) {
        String baseUrl = System.getProperty("baseUrl", "http://localhost:8080");
        SignInPage signIn = new SignInPage(driver).open(baseUrl);
        signIn.enterCredentials(email, password).submit();
        assertEquals(expectedHeading, signIn.accountHeadingText());
    }
}

Run with mvn test -DbaseUrl=http://localhost:8080 after configuring the project’s compiler and test-runner plugins. This command assumes a local application listening at that URL and a working Chrome installation. Add negative, validation, and boundary cases where they represent distinct behavior; do not inflate one scenario into many indistinguishable rows simply to call the suite data-driven.

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 waits for the condition the next action needs

A page-load event does not mean a JavaScript-driven application is ready for the next interaction. Selenium describes races between application state and test commands as a primary source of flaky tests. Use an explicit wait for the actual readiness condition—visibility, clickability, a URL change, or a relevant state transition—rather than a fixed sleep.

  • Wait for visibility before reading text or interacting with a control.
  • Wait for clickability when an overlay or asynchronous render could temporarily prevent a click.
  • Wait for the expected URL or page state after navigation or submission.
  • Keep timeouts bounded and meaningful; a longer timeout can hide a slow or broken application rather than fix it.

Selenium warns against mixing implicit and explicit waits because their interaction can produce unpredictable timeout behavior. Prefer explicit waits for application conditions and avoid relying on arbitrary delays. The waiting strategies documentation explains the underlying timing issue.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Run locally first, then decide whether Grid is warranted

Local WebDriver keeps the initial setup simple. Add Selenium Grid when you need remote sessions, parallel distribution, or a browser/platform matrix that is impractical on one machine. Grid routes WebDriver commands to remote browser sessions; the trade-off is that your team must operate or provision the Grid endpoint and account for network access, capacity, and diagnostics.

Connect a test to a remote Grid

After launching a standalone Grid server using the instructions for your chosen Selenium version, point the test at its configured endpoint. The quick-start example uses http://localhost:4444; a hosted or distributed Grid may use a different reachable URL.

import java.net.URI;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;

WebDriver driver = new RemoteWebDriver(
    URI.create("http://localhost:4444").toURL(),
    new ChromeOptions()
);

Use the same lifecycle cleanup as for local drivers, calling quit() so the remote session is released. Grid is an execution topology choice, not a replacement for Page Objects, test assertions, or good wait behavior. Read the Grid getting started guide and Grid overview for setup and architecture details.

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

Choose framework and execution options by actual need

When another runner or BDD layer helps

Compare runners on language/runtime compatibility, team familiarity, parameterization, parallel execution, plugins, and CI/reporting integration. Selenium notes TestNG’s parallel and parameterized features; those may matter for a Java team with that requirement. For behavior-driven tests, add a layer only when shared scenario language benefits product, QA, and engineering participants. Keep browser work in page/component objects rather than writing locators into feature definitions.

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

When to add more structure

  • Add a browser factory when multiple browsers, local/remote modes, or configuration profiles are real use cases.
  • Add reusable components when multiple pages share meaningful UI elements.
  • Move large, maintained input sets into resource files or a data service when inline parameter sources become hard to review.
  • Add parallelism only after tests are isolated: no shared browser sessions, mutable cross-test state, or conflicting test data.

Troubleshooting common failures

Driver cannot start or Selenium Manager cannot obtain a driver

Check that the browser is installed and supported in the runner environment, that Selenium and browser versions are intentionally managed, and that the process can reach required download/version endpoints. In restricted corporate networks, configure approved proxy/network access or provision a compatible driver through the environment. Confirm platform support, especially on Linux ARM/aarch64.

Element not found or interaction is intermittent

Verify the selector against the current DOM, check whether the element is inside an iframe or shadow root, and wait for the specific condition that makes it available. A navigation completing does not guarantee that a client-rendered component has appeared. Avoid replacing a missing condition with a longer fixed sleep.

Click is intercepted or times out

Determine whether a modal, animation, cookie banner, or loading overlay is covering the target. Wait for the overlay to disappear or for the control to become clickable; if the UI is genuinely blocked, fix the application or test setup rather than forcing a JavaScript click that bypasses user behavior.

Tests pass alone but fail in a suite

Look for shared browser state, reused accounts, leftover sessions, test-order dependencies, and parallel tests mutating the same data. Create a fresh driver per test unless there is a deliberate, isolated reason not to, and always quit it during cleanup.

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

Remote session cannot connect or Grid has no capacity

Confirm the Grid URL is reachable from the test process, the server is running, the requested browser capability is available, and session capacity is not exhausted. Check Grid logs and network/firewall rules; remote execution adds infrastructure failure modes beyond local WebDriver.

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.

Performance, reliability, and cost considerations

For reliability, prioritize isolation, stable selectors, condition-based waits, cleanup, and clear failure diagnostics before increasing timeouts or adding more framework layers. For performance, parallel execution can reduce elapsed time only when Grid and the application can sustain concurrent sessions; it also increases infrastructure and test-data coordination demands. Selenium itself does not prescribe a universal speed or cost figure for a framework—those depend on browser capacity, CI resources, test duration, and the application under test. Pin dependencies and review upgrades with the browser and CI image rather than assuming one version combination works everywhere.

Or skip the browser setup

If the job is to capture a page image or PDF rather than exercise interactive behavior, a screenshot API may fit better than maintaining a browser test just for a capture. ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF; its cleanup can accept cookie/consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture, with each step independently switchable. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify page verdict and billing status. AI agents can use its MCP tools, including take_screenshot, get_page_info, and capture_pdf.

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. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.

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

Frequently Asked Questions

Does Selenium provide a built-in hybrid framework?

No. Selenium provides WebDriver and related components, but teams assemble their test runner, data approach, page objects, and support code to fit their project.

Should I use Page Factory in this framework?

This guide uses ordinary Page Objects and explicit locators; Selenium’s documented Page Object pattern does not require Page Factory.

Can the same design work with Python or JavaScript?

Yes. Keep the separation of test intent, page operations, data, and browser lifecycle, but use the runner and idioms appropriate to that language binding.

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.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.