How to Install Selenium 4
Install Selenium 4 in Python, Java, C#, Ruby, or Node.js, start a browser session, and troubleshoot driver setup with Selenium Manager.
Install Selenium 4 with the package manager or build tool for your programming language. Selenium is a set of language bindings, not a single desktop installer. In most supported environments, you do not need to download ChromeDriver separately: Selenium Manager can find or download a compatible driver when your code starts a browser.
At the time of the research for this guide (October 3, 2026), Selenium 4.49.0 is the stable release, dated September 9, 2026; 4.50.0 is listed as a nightly snapshot. Release numbers change, so check the official Selenium downloads page before pinning a version.
1. Choose your language and install Selenium
Use the dependency method your project already uses. Pin a version for repeatable builds; omit the version when you intentionally want the package manager to resolve the latest compatible release. The examples below use 4.49.0 as the researched stable version. Check the relevant registry metadata for the selected release’s current runtime requirements.
Python
From your project directory, create and activate a virtual environment if you use one, then install the binding:
python -m venv .venv
# macOS or Linux:
source .venv/bin/activate
# Windows PowerShell:
.venv\Scripts\Activate.ps1
python -m pip install selenium
For a pinned dependency, add this line to requirements.txt:
selenium==4.49.0
Then install the project dependencies with python -m pip install -r requirements.txt. Use the Python interpreter associated with your project environment; installing into a different interpreter is a common reason an editor cannot import Selenium.
Java
Use Maven or Gradle and keep Selenium in the project’s dependency file. For Maven, add this dependency inside <dependencies> in pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.49.0</version>
</dependency>
For Gradle, add to build.gradle:
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.seleniumhq.selenium:selenium-java:4.49.0'
}
If your application uses Selenium outside tests, use the dependency configuration appropriate to that application. Consult the current Selenium install guide and your JDK’s compatibility requirements before upgrading.
.NET / C#
From the directory containing your project file, install the NuGet package:
dotnet add package Selenium.WebDriver --version 4.49.0
The Package Manager Console alternative is:
Install-Package Selenium.WebDriver -Version 4.49.0
You can also pin it in the project’s .csproj:
<ItemGroup>
<PackageReference Include="Selenium.WebDriver" Version="4.49.0" />
</ItemGroup>
Ruby
For a project using Bundler, add a pinned dependency to your Gemfile:
gem "selenium-webdriver", "4.49.0"
Then run bundle install. To install globally instead, run:
gem install selenium-webdriver -v 4.49.0
JavaScript / Node.js
In your Node.js project, install the package and pin the version:
npm install --save-exact selenium-webdriver@4.49.0
To allow npm to select its current compatible version, use npm install selenium-webdriver. Check the package’s Node support policy for the chosen release.
2. Start a browser session
After installing the binding, try a small program that opens a page, reads its title, and closes the browser even if an error occurs. Selenium Manager is invoked by the bindings when no driver has been otherwise configured.
Python example
from selenium import webdriver
with webdriver.Chrome() as driver:
driver.get("https://example.com")
print(driver.title)
Save as first_selenium.py and run python first_selenium.py.
Java example
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstSelenium {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
try {
driver.get("https://example.com");
System.out.println(driver.getTitle());
} finally {
driver.quit();
}
}
}
Save as FirstSelenium.java in the source tree configured by your Maven or Gradle project, then run it through that build tool.
C# example
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://example.com");
Console.WriteLine(driver.Title);
Run the project with dotnet run.
Ruby example
require "selenium-webdriver"
Selenium::WebDriver.for(:chrome) do |driver|
driver.navigate.to "https://example.com"
puts driver.title
end
Run it with ruby first_selenium.rb, or use bundle exec ruby first_selenium.rb when installed through Bundler.
Node.js example
const { Builder } = require('selenium-webdriver');
(async () => {
const driver = await new Builder().forBrowser('chrome').build();
try {
await driver.get('https://example.com');
console.log(await driver.getTitle());
} finally {
await driver.quit();
}
})();
Save as first_selenium.js and run node first_selenium.js.
3. Understand browser and driver setup
Selenium WebDriver communicates with a browser through a browser-specific driver. Selenium Manager has shipped with Selenium releases since 4.6. When a binding starts a browser and no driver is already configured, Manager can detect the browser version, resolve and download a compatible driver, and cache it. Selenium 4.11 added browser management capabilities for supported Chrome, Firefox, and Edge installations. See the Selenium Manager documentation.
This means the usual first attempt is to install the binding and run a WebDriver example. You can still provide a driver manually or use another driver-management tool when your environment requires explicit control. Selenium Manager is not supported equally on all platforms: its documentation says normal operation is not expected on Linux ARM64/aarch64, 32-bit systems, or Raspberry Pi. Custom Linux package-manager browser installations may also need explicit browser or driver paths.
4. Configure the project and environment
- Pin dependencies when repeatability matters. Commit the lockfile or dependency file your ecosystem uses, and update Selenium deliberately.
- Check the runtime floor for the exact release. Python, Java, Ruby, and Node.js requirements can change; check the release’s registry metadata or current Selenium install documentation. Do not rely on old minimum-version snippets.
- Use the project environment. Activate the virtual environment, use the correct JDK, restore NuGet packages, or run Node and Ruby commands from the project that owns the dependency.
- Allow first-run downloads where applicable. Selenium Manager may need network access to resolve and retrieve a driver. In locked-down environments, preconfigure a driver or browser path according to Selenium’s documentation.
- Use the browser you intend to automate. If a browser is absent, install it through your operating system or an officially supported Selenium Manager browser-management workflow.
5. Troubleshoot installation and startup errors
| Symptom | Likely cause | Fix |
|---|---|---|
ModuleNotFoundError: No module named 'selenium' |
Selenium was installed into a different Python interpreter or environment. | Activate the project environment, then run python -m pip install selenium with the same python that runs the script. In an editor, select that interpreter. |
Java reports that org.openqa.selenium cannot be found |
The dependency is missing, the build file was not reloaded, or the source is being compiled outside the configured build. | Check the Maven or Gradle dependency, reload the project, and run through the build tool so it resolves Maven Central dependencies. |
dotnet restore cannot find the package |
NuGet sources may be missing or misconfigured, or the project could not reach its package source. | Check the project’s NuGet configuration, including any nuget.config, verify the package source, then restore again. |
cannot load such file -- selenium-webdriver |
The gem is not installed in the Ruby environment used by the command. | Run bundle install and execute with bundle exec, or install the gem into the active Ruby environment. |
Node reports Cannot find module 'selenium-webdriver' |
The package is not installed in the current project or Node is running from another directory. | Run npm install selenium-webdriver in the project and start the script from that project. |
| Driver cannot be found or downloaded | Manager could not access the network, the platform is unsupported, or a custom browser install was not detected. | Check network/proxy access and Selenium Manager diagnostics; on unsupported or custom setups, install a compatible driver and configure its path explicitly. |
| Browser and driver versions do not match | A manually configured driver is incompatible with the installed browser, or a stale path takes precedence over Manager. | Remove the unintended driver override or update the configured driver to match the browser. Re-run with a clean, known configuration. |
| Browser starts then exits, or Linux reports missing libraries | The browser lacks operating-system libraries or cannot run with the current user/container permissions. | Install the browser’s required system libraries and confirm it can launch in that environment. Check the browser and Selenium Manager documentation for platform-specific requirements. |
6. Performance, reliability, and cost
The Selenium binding itself is a project dependency; a working run also depends on a compatible browser and driver, runtime support, permissions, and sometimes network access for initial driver resolution. Selenium Manager caches resolved assets, which can avoid repeating downloads in a persistent environment. Ephemeral CI workers may need network access on each fresh worker unless the environment preserves an appropriate cache or supplies drivers itself.
For more reliable runs, pin the binding version, keep browser and driver setup consistent across local development and CI, close sessions with quit() even after failures, and use explicit waits in browser automation rather than assuming a page is ready immediately. Selenium installation itself is software-based; no paid Selenium installer or hardware purchase is required by the setup steps here. Browser execution still uses the compute and storage resources of the machine or CI environment running it.
Or skip the browser setup
If your goal is to capture a webpage image or PDF rather than interact with a browser, ScreenshotNeo provides a website screenshot API and MCP server. Its API takes one GET request with a URL and can return PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
- Cookie banners and consent layers, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
- Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing. Responses identify page verdict and billing status in headers.
- An MCP server lets AI agents use
take_screenshot,get_page_info, andcapture_pdf. - 1,000 screenshots per month are free with no card; paid plans start at $5 for 3,000 screenshots.
Sign up free for 1,000 screenshots a month, with no card required.
FAQ
Is Selenium 4 a desktop app I install once?
No. Install the language binding in each project using that language’s package manager or build tool.
Do I need to install ChromeDriver separately?
Usually not in a supported environment. Selenium Manager can resolve a driver automatically when one has not been configured. Platform limits, custom browser installs, or network restrictions can require manual setup.
Can I use Selenium in VS Code?
Yes. Install the binding into the same project environment selected by VS Code, then run the project with its normal language tooling.
Should I use the nightly version?
For a general setup, use the latest stable release. Use a nightly snapshot only when you specifically need to evaluate changes that are not yet in a stable release.


