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 DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk6 min

How to Integrate Selenium WebDriver with Jenkins

Run an existing Selenium test suite in Jenkins with a Pipeline, a compatible browser environment, and useful test reporting. Learn when to use a local agent, Selenium Grid, or Docker.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Integrate Selenium WebDriver with Jenkins by running your project’s existing test command in a Jenkins Pipeline on an agent that has the required runtime and browser environment. For Java projects, declare Selenium in the build tool—commonly Maven—and let Jenkins orchestrate the build. Start with a browser installed on the agent; use Selenium Grid when you need remote browsers, parallel sessions, or broader browser and operating-system coverage.

Before you add Selenium tests to Jenkins

Jenkins does not need a Selenium-specific job type. Your project owns the Selenium dependency, test framework, and test command; the Pipeline checks out the code, runs that command, and publishes the resulting reports.

  • Confirm the tests pass using the same command developers run locally.
  • Identify the project runtime, Selenium binding, test framework, browser, and driver requirements.
  • Record required environment variables, credentials, and any application or test-data setup.
  • Identify where the test framework writes machine-readable reports and failure artifacts.

Declare Selenium in the project

For Java, Selenium’s installation guide demonstrates adding org.seleniumhq.selenium:selenium-java as a Maven dependency. Select a current release compatible with your project’s Java baseline; there is no single version number that fits every project. See the Selenium library installation guide and check current Selenium downloads before pinning a version.

Run the test command in a Jenkins Pipeline

This declarative Pipeline illustrates a Maven project whose tests run with mvn -B test and write JUnit XML files under target/surefire-reports/. Adjust the command and report path to match your repository; the sample paths are not universal.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps { checkout scm }
    }
    stage('WebDriver tests') {
      steps {
        sh 'mvn -B test'
      }
    }
  }
  post {
    always {
      junit 'target/surefire-reports/*.xml'
    }
  }
}

Use sh for a Unix-like agent; on Windows, use the appropriate batch step and command. Set an agent label instead of any when only certain agents have the needed browser or runtime. The junit step records test results in Jenkins when matching XML reports exist.

Manage Maven and JDK through Jenkins when useful

The Jenkins Pipeline Maven Integration plugin provides withMaven for Maven configuration. Depending on your Jenkins setup, it can select configured JDK and Maven installations, apply settings, and support Maven report publishing. Use it when managed tools or settings are part of your team’s workflow; a plain Maven command can be enough when the agent already has the correct tools. See the Pipeline Maven Integration documentation.

Choose where the browser runs

Approach Best fit Trade-off
Browser on a Jenkins agent A small suite or first CI integration Simple to operate, but the agent’s browser and driver must remain compatible and launchable.
Selenium Grid Remote browsers, parallel sessions, or browser and platform coverage Adds a shared remote execution service, network configuration, and security responsibilities.
Dockerized test stage Packaging test dependencies for more repeatable execution Requires Docker-capable Jenkins execution and maintained images; browser and Grid networking still need attention.

Start with a local browser

For the simplest design, install a supported browser on the Jenkins agent and ensure the agent user can launch it. The current Selenium Grid getting-started guide lists installed browsers and drivers as prerequisites and notes that Selenium Manager can configure drivers automatically when enabled. Verify browser, driver, Selenium, and Java compatibility for the versions you select rather than relying on assumptions from an older tutorial. The guide currently lists Java 11 or higher as a getting-started prerequisite; check the requirements for your selected releases.

Move to Grid for remote or parallel sessions

Selenium Grid routes WebDriver commands to remote browser instances and supports parallel execution and browser or platform coverage. Configure the test code to create a RemoteWebDriver pointed at the Grid URL; the Selenium getting-started guide uses port 4444 as the default endpoint and describes standalone and Hub/Node deployment roles. See the Selenium Grid overview and Grid getting-started guide.

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

A Grid endpoint is sensitive infrastructure, not a public testing URL. Selenium warns that an exposed Grid can let outsiders reach infrastructure, internal applications, and files, or run binaries. Keep it on a private network or restrict access with appropriate firewall and access controls.

Use Docker when its boundaries are clear

Jenkins Pipeline can execute stages in Docker images when the Docker Pipeline plugin is installed and the agent is configured to run Docker. A stage-specific image or repository Dockerfile can package runtime dependencies. You still need to plan browser versions, fonts, shared memory, and networking to an application or Grid. Consult Jenkins’ Docker with Pipeline guide for plugin and agent requirements.

Publish useful results and failure artifacts

Publish the test framework’s machine-readable results with Jenkins’ JUnit support, and preserve screenshots or logs when a test fails. Keep test assertions distinct from environment failures so a missing browser, unreachable Grid, exhausted session capacity, or incompatible versions do not look like an application regression. Report formats, output paths, and useful artifacts depend on the test framework and project.

Selenium’s Grid guide suggests 1 CPU and 1 GB RAM per browser as a reference allocation, while cautioning that actual resource needs vary and should be measured. Treat this as a starting point for capacity planning, not a guarantee or benchmark.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common Jenkins and WebDriver failures

Symptom Likely cause What to check or change
Browser does not start on the agent Browser missing, agent user lacks permissions, or required runtime dependencies are absent. Run the test as the Jenkins agent user; confirm the browser is installed and launchable in that environment.
Driver or browser version error Selected browser, driver, Selenium, or Java versions are incompatible. Check compatibility for the exact versions in use. If Selenium Manager is enabled, confirm the agent can use it and reach the resources it needs.
Could not connect to Grid Wrong RemoteWebDriver URL, Grid not running, or agent-to-Grid network access blocked. Verify the configured endpoint and port, Grid health, and network path from the Jenkins agent.
Grid sessions fail under load Insufficient browser slots or host resources for concurrent sessions. Check Grid capacity and host utilization; reduce test concurrency or add capacity based on measured demand.
Build passes but Jenkins shows no test results The JUnit glob does not match the report location, or the test command did not generate reports. Inspect the workspace after the test stage and set the junit path to the actual report files.
Docker stage cannot reach the application or Grid Container network configuration does not provide the required route or hostname. Check the container’s network and service names, then verify reachability from inside the stage environment.
Tests behave differently on CI Agent configuration, environment variables, browser settings, or test data differ from local execution. Compare the runtime and browser environment and provide explicit configuration and stable test data.

Do not make the legacy Jenkins Selenium plugin the default

The current Jenkins Selenium plugin page describes a legacy Selenium 3 Grid plugin, reports an unresolved warning about absent CSRF protection and potential OS command injection, and says the plugin is up for adoption. Prefer ordinary Pipeline steps and a maintained project or Grid setup unless you are reviewing an existing deployment and have assessed its risks.

Or skip the browser setup

If the task is to capture a web page rather than run interactive browser tests, ScreenshotNeo offers a screenshot API and MCP server. One GET request returns an image or PDF; it is not a replacement for Selenium assertions or browser interaction tests. The API removes supported cookie and consent banners, newsletter popups, and chat widgets before capture, with each step configurable. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. AI agents can use its MCP tools, including take_screenshot, get_page_info, and capture_pdf. Plans include 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. See ScreenshotNeo.

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 parameters and setup, then sign up for 1,000 free screenshots a month with no card.

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 *

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.