[Solved] session not created: This version of ChromeDriver only supports Chrome version xx (SessionNotCreated) - Selenium with C# .NET

session not created: This version of ChromeDriver only supports Chrome version

This blog is going to explain how to fix the ‘session not created: This version of ChromeDriver only supports Chrome version xx (SessionNotCreated)’ issue. That is how to get the same version of chrome browser and chromedriver. This problem is due to the fact that the Chrome browser version and the Chromedriver version are different. For example, the Chrome browser version you installed may be 98.0.4758.102 and your Chrome driver version may be 99.0.4844.51.

To fix the problem, you need to download the same version of Chrome browser installed on your computer. Let's see how to achieve this.

First you need to install the required packages using the nuget.

To manage the WebDriver, install WebDriverManager package
Install-Package WebDriverManager

To manage selenium webdriver, install Selenium.WebDriver package
Install-Package Selenium.WebDriver

The final one is Sample Console Application code. The code below is a console application code. In the code, I got the current version of Chrome browser installed on the computer. Then find the version of Chrome browser and download the same Chrome driver. Then an example was created for the Chrome driver and taken to the website

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;
using WebDriverManager.Helpers;

namespace SampleConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
             // Download the same version of chromedriver
            var chromeDriverPath = new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);

            // Get a path of chromedriver
            string chromeDirectoryPath = System.IO.Path.GetDirectoryName(chromeDriverPath);

            // Create instance by passing the path of the chromedriver directory
            IWebDriver driver = new ChromeDriver(chromeDirectoryPath);

            driver.Navigate().GoToUrl("https://www.google.com/");
        }
    }
}

The below one is a output of above code
session not created: This version of ChromeDriver only supports Chrome version

I hope this helps you. Keep coding.

Comments

Popular posts from this blog

Entity Framework Core (EF) with SQL Server LocalDB

Exploring EventCallback in Blazor: Building Interactive Components

A Step-by-Step Guide to Implementing Identity in ASP.NET Core MVC