Skip to main content
Login Register
Code2night
  • Home
  • Blog Archive
  • Learn
    • Tutorials
    • Videos
  • Interview Q&A
  • Languages
    • Angular Angular js ASP.NET Asp.net Core ASP.NET Core, C# C C# C#, ASP.NET Core, Dapper
      C#, ASP.NET Core, Dapper, Entity Framework DotNet HTML/CSS Java JavaScript Node.js Python Python 3.11, Pandas, SQL
      Python 3.11, SQL Python 3.11, SQLAlchemy Python 3.11, SQLAlchemy, SQL Python 3.11, SQLite React Security SQL Server TypeScript
  • Post Blog
  • Tools
    • Beautifiers
      JSON Beautifier HTML Beautifier XML Beautifier CSS Beautifier JS Beautifier SQL Formatter
      Dev Utilities
      JWT Decoder Regex Tester Diff Checker Cron Explainer String Escape Hash Generator Password Generator
      Converters
      Base64 Encode/Decode URL Encoder/Decoder JSON to CSV CSV to JSON JSON to TypeScript Markdown to HTML Number Base Converter Timestamp Converter Case Converter
      Generators
      UUID / GUID Generator Lorem Ipsum QR Code Generator Meta Tag Generator
      Image Tools
      Image Converter Image Resizer Image Compressor Image to Base64 PNG to ICO Background Remover Color Picker
      Text & Content
      Word Counter PDF Editor
      SEO & Web
      SEO Analyzer URL Checker World Clock
  1. Home
  2. Blog
  3. Java
  4. org.openqa.selenium.SessionNotCreatedException: session not created exception

org.openqa.selenium.SessionNotCreatedException: session not created exception

Date- Aug 20,2023 Updated Jan 2026 5761
Java ChromeDriver

Overview of org.openqa.selenium.SessionNotCreatedException

The SessionNotCreatedException is thrown when Selenium fails to establish a new session with the browser. This error can arise from various underlying issues, such as version incompatibilities, misconfigurations, or environmental problems. Understanding the reasons behind this exception is crucial for developers and testers who rely on Selenium for web application testing.

In real-world scenarios, this exception might surface during automated test runs, leading to halted test executions and delayed releases. Identifying and resolving the root cause of the exception not only improves the reliability of your test suite but also enhances the overall efficiency of your development process.

Prerequisites

Before diving into troubleshooting the SessionNotCreatedException, ensure that you have the following prerequisites:

  • A compatible version of Java installed on your machine.
  • The latest version of Selenium WebDriver.
  • Appropriate WebDriver for the browser you intend to automate (e.g., ChromeDriver for Chrome).
  • Access to the browser you want to test on, with any necessary configurations set up.
  • Basic knowledge of Java programming and how Selenium works.

Driver Configuration Issues

One of the primary reasons for encountering the SessionNotCreatedException is improper driver configuration. Each browser has its own WebDriver, and they must be compatible with the browser version in use. If there is a mismatch, Selenium will fail to create a session.

To ensure compatibility, always check the release notes of both the browser and the corresponding WebDriver. For example, if you are using Chrome version 95, make sure you download ChromeDriver version 95.x.x. You can find the correct versions on the official Selenium and browser websites.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class DriverConfigExample {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "path/to/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.example.com");
        // Perform test actions
        driver.quit();
    }
}

Incorrect WebDriver Path

Another common issue leading to the SessionNotCreatedException is specifying an incorrect path to the WebDriver executable. If Selenium cannot locate the WebDriver, it will be unable to start a new session.

To resolve this, ensure that the path you provide in your code is correct and accessible. You can use absolute paths for clarity, especially when running tests in CI/CD environments where the context might differ.

System.setProperty("webdriver.chrome.driver", "C:/path/to/chromedriver.exe");

Browser Version Mismatch

Using an outdated version of the WebDriver can also lead to session creation failures. Each new browser version may introduce changes that require updates to the WebDriver.

To avoid this issue, regularly update your WebDriver to match the browser version you are using. Most browsers will notify you of updates, and the WebDriver can be downloaded from their respective repositories.

// Check for the latest version of ChromeDriver
// Ensure it's compatible with the installed version of Chrome

Browser Configuration

Some browsers may require additional configurations to work seamlessly with Selenium. For instance, Chrome may need the path to its binary specified in certain environments.

To set the binary path, you can use the following code snippet:

import org.openqa.selenium.chrome.ChromeOptions;

ChromeOptions options = new ChromeOptions();
options.setBinary("C:/path/to/chrome.exe");
WebDriver driver = new ChromeDriver(options);

Firewall or Network Issues

Network connectivity issues can also prevent Selenium from creating a session. Firewalls or proxy settings might block the necessary connections between your test scripts and the browser.

To troubleshoot this, check your network settings and ensure that your firewall allows traffic for the browser and WebDriver. You may need to adjust your proxy settings in your Selenium configuration.

Driver Initialization

Improper initialization of the WebDriver can lead to the SessionNotCreatedException. Ensure that you are correctly creating an instance of the WebDriver and configuring it before starting a session.

Here's a complete example of initializing the WebDriver:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class DriverInitializationExample {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "path/to/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.example.com");
        // Your test logic here
        driver.quit();
    }
}

Runtime Environment

When running Selenium tests in a specific runtime environment, such as a CI/CD pipeline, ensure that the environment has all necessary dependencies and configurations. Missing dependencies can lead to session creation failures.

To mitigate this, verify that the runtime environment includes the correct versions of Java, WebDriver, and any required browser binaries. Configurations should align with those of your local development environment to minimize discrepancies.

Edge Cases & Gotchas

There are several edge cases and gotchas that developers should be aware of when dealing with the SessionNotCreatedException. For instance, if you are using a version of the browser that is still in beta, this may lead to unpredictable behavior with WebDriver.

Additionally, running tests on virtual machines or containers can introduce unique challenges. Ensure that the virtual environment has access to the necessary display drivers, especially for browsers that require a graphical interface.

Performance & Best Practices

To optimize your Selenium tests and avoid the SessionNotCreatedException, consider the following best practices:

  • Always keep your WebDriver and browser versions in sync.
  • Use a reliable method to manage WebDriver binaries, such as WebDriverManager, to automate the download and setup process.
  • Implement error handling in your test scripts to gracefully manage exceptions and retry logic.
  • Run tests in headless mode when possible to improve performance and reduce resource consumption.

Conclusion

In summary, the SessionNotCreatedException can arise from various issues related to driver configuration, browser compatibility, and environmental factors. By understanding and addressing these common pitfalls, you can enhance the reliability of your Selenium tests.

  • Ensure that your WebDriver version matches your browser version.
  • Double-check paths to WebDriver executables.
  • Consider network configurations and firewall settings.
  • Implement best practices for WebDriver management and test execution.
orgopenqaseleniumSessionNotCreatedException session not created exception

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

java.lang.IllegalStateException: The driver executable does not exist
Aug 21, 2023
NoSuchwindowException in Java
Aug 31, 2023
Can only iterate over an array or an instance of java.lang.Iterable
Aug 31, 2023
How to Install Eclipse Editor For Selenium
Aug 22, 2023
Previous in Java
Automating Keyboard and Mouse Events.
Next in Java
java.lang.IllegalStateException: The driver executable does not e…
Buy me a pizza

Comments

On this page

🎯

Interview Prep

Ace your Java interview with curated Q&As for all levels.

View Java Interview Q&As

More in Java

  • User-defined data types in java 6247 views
  • Master Java Type Casting: A Complete Guide with Examples 6220 views
  • How to add (import) java.util.List; in eclipse 5807 views
  • Java Program to Display Fibonacci Series 4931 views
  • java.lang.IndexOutOfBoundsException 4284 views
View all Java posts →

Tags

AspNet C# programming AspNet MVC c programming AspNet Core C software development tutorial MVC memory management Paypal coding coding best practices data structures programming tutorial tutorials object oriented programming Slick Slider StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1770
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
  • SEO Analyzer
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • SQL Formatter
  • Diff Checker
  • Regex Tester
  • Markdown to HTML
  • Word Counter
More Tools
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Base64 Encoder
  • JWT Decoder
  • UUID Generator
  • Image Converter
  • PNG to ICO
  • SEO Analyzer
By Language
  • Angular
  • Angular js
  • ASP.NET
  • Asp.net Core
  • ASP.NET Core, C#
  • C
  • C#
  • C#, ASP.NET Core, Dapper
  • C#, ASP.NET Core, Dapper, Entity Framework
  • DotNet
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • Python 3.11, Pandas, SQL
  • Python 3.11, SQL
  • Python 3.11, SQLAlchemy
  • Python 3.11, SQLAlchemy, SQL
  • Python 3.11, SQLite
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page
We use cookies to improve your experience and analyze site traffic. By clicking Accept, you consent to our use of cookies. Privacy Policy
Accessibility
Text size
High contrast
Grayscale
Dyslexia font
Highlight links
Pause animations
Large cursor