WebDriverManager 2.17.2

dotnet add package WebDriverManager --version 2.17.2
NuGet\Install-Package WebDriverManager -Version 2.17.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WebDriverManager" Version="2.17.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WebDriverManager --version 2.17.2
#r "nuget: WebDriverManager, 2.17.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WebDriverManager as a Cake Addin
#addin nuget:?package=WebDriverManager&version=2.17.2

// Install WebDriverManager as a Cake Tool
#tool nuget:?package=WebDriverManager&version=2.17.2

Info
Built-in manager was released by Selenium "Selenium Manager", which will automatically download the most suitable version and platform WebDriver executable file. So now, you can run applications that use Selenium and manipulates web browsers without this package.

Build status NuGet

WebDriverManager.Net

Table of contents

Info

This small library aimed to automate the Selenium WebDriver binaries management inside a .Net project.

If you have ever used Selenium WebDriver, you probably know that in order to use some browsers (for example Chrome) you need to download a binary which allows WebDriver to handle the browser. In addition, the absolute path to this binary must be set as part of the PATH environment variable or manually copied to build output folder (working directory).

This is quite annoying since it forces you to link directly this binary in your source code. In addition, you have to check manually when new versions of the binaries are released. This library comes to the rescue, performing in an automated way all this dirty job for you.

WebDriverManager is open source, released under the terms of MIT license.

Installation

WebDriverManager.Net can be downloaded from NuGet. Use the GUI or the following command in the Package Manager Console:

PM> Install-Package WebDriverManager

Usage

Target is netstandard2.0.

After installation you can let WebDriverManager.Net to do manage WebDriver binaries for your application/test. Take a look to this NUnit example which uses Chrome with Selenium WebDriver:

using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;

namespace Test
{
    [TestFixture]
    public class Tests
    {
        private IWebDriver _webDriver;

        [SetUp]
        public void SetUp()
        {
            new DriverManager().SetUpDriver(new ChromeConfig());
            _webDriver = new ChromeDriver();
        }

        [TearDown]
        public void TearDown()
        {
            _webDriver.Quit();
        }

        [Test]
        public void Test()
        {
            _webDriver.Navigate().GoToUrl("https://www.google.com");
            Assert.True(_webDriver.Title.Contains("Google"));
        }
    }
}

Notice that simply adding new DriverManager().SetUpDriver(<config>) does magic for you:

  1. It checks the latest version of the WebDriver binary file
  2. It downloads the binary WebDriver if it is not present in your system

So far, WebDriverManager supports Chrome, Microsoft Edge, Firefox(Marionette), Internet Explorer, Opera or PhantomJS configs (just change <config> to preferred config):

new ChromeConfig();
new EdgeConfig();
new FirefoxConfig();
new InternetExplorerConfig();
new OperaConfig();
new PhantomConfig();

Advanced

You can use WebDriverManager in two ways:

  1. Automatic
  2. Manual
Automatic way:
new DriverManager().SetUpDriver(new <Driver>Config());

You can also specify version:
new DriverManager().SetUpDriver(new ChromeConfig(), "2.25")

Or architecture:
new DriverManager().SetUpDriver(new ChromeConfig(), "Latest", Architecture.X32)

Or version and architecture:
new DriverManager().SetUpDriver(new ChromeConfig(), "2.25", Architecture.X64)

Or you can specify to automatically download a driver matching the version of the browser that is installed in your machine (only for Chrome, Edge, Firefox and Internet Explorer):
new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);

Manual way:
new DriverManager().SetUpDriver(
    "https://chromedriver.storage.googleapis.com/2.25/chromedriver_win32.zip",
    Path.Combine(Directory.GetCurrentDirectory(), "chromedriver.exe"),
    "chromedriver.exe"
);

If you want use your own implementation you need to create driver config and use it for set up(ex get, setup and work with phantomjs driver from taobao mirror):

public class TaobaoPhantomConfig : IDriverConfig
{
    public string GetName()
    {
        return "TaobaoPhantom";
    }

    public string GetUrl32()
    {
        return "https://npm.taobao.org/mirrors/phantomjs/phantomjs-<version>-windows.zip";
    }

    public string GetUrl64()
    {
        return GetUrl32();
    }

    public string GetBinaryName()
    {
        return "phantomjs.exe";
    }

    public string GetLatestVersion()
    {
        using (var client = new WebClient())
        {
            var doc = new HtmlDocument();
            var htmlCode = client.DownloadString("https://bitbucket.org/ariya/phantomjs/downloads");
            doc.LoadHtml(htmlCode);
            var itemList =
                doc.DocumentNode.SelectNodes("//tr[@class='iterable-item']/td[@class='name']/a")
                    .Select(p => p.InnerText)
                    .ToList();
            var version = itemList.FirstOrDefault()?.Split('-')[1];
            return version;
        }
    }
}

...

new DriverManager().SetUpDriver(new TaobaoPhantomConfig());

Also you can implement your own services for download binaries and manage variables:

public class CustomBinaryService : IBinaryService
{
    public string SetupBinary(string url, string zipDestination, string binDestination, string binaryName)
    {
        ...
        // your implementation
        ...
    }
}

public class CustomVariableService : IVariableService
{
    public void SetupVariable(string path)
    {
        ...
        // your implementation
        ...
    }
}

...

new DriverManager(new CustomBinaryService(), new CustomVariableService()).SetUpDriver(new FirefoxConfig());

Or you can modify existed drivers and change only necessary fields(same example):

public class TaobaoPhantomConfig : PhantomConfig
{
    public override string GetName()
    {
        return "TaobaoPhantom";
    }

    public override string GetUrl32()
    {
        return "https://npm.taobao.org/mirrors/phantomjs/phantomjs-<version>-windows.zip";
    }
}

...

new DriverManager().SetUpDriver(new TaobaoPhantomConfig());

Using with proxy:

new DriverManager().WithProxy(previouslyInitializedProxy).SetUpDriver(new ChromeConfig());

You can also set the environment variables HTTP_PROXY and/or HTTPS_PROXY to use a proxy when retrieving the drivers. This does not require any changes in the setup of DriverManager in C#.

Thanks

Thanks to the following companies for generously providing their services/products to help improve this project:

Logo Description
AppVeyor AppVeyor is a hosted, distributed continuous integration service used to build and test projects hosted at GitHub on a Microsoft Windows virtual machine.
BrowserStack BrowserStack is a cloud-based cross-browser testing tool that enables developers to test their websites across various browsers on different operating systems and mobile devices, without requiring users to install virtual machines, devices or emulators.
GitHub GitHub is a web-based Git repository hosting service. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.
JetBrains JetBrains (formerly IntelliJ) is a software development company whose tools are targeted towards software developers and project managers.
SonarQube SonarQube (formerly Sonar) is an open source platform for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells and security vulnerabilities on 20+ programming languages.

About

WebDriverManager.Net (Copyright © 2016-2024) is a personal project of Aliaksandr Rasolka licensed under MIT license. Comments, questions and suggestions are always very welcome!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (48)

Showing the top 5 NuGet packages that depend on WebDriverManager:

Package Downloads
Pangolin

A framework for declarative UI testing for ASP.NET apps. Browsers: All browsers can be used. With the possibility of automatic update to the latest version.

Magenic.Maqs.Selenium

Magenic's automation quick start framework

Aquality.Selenium

Wrapper over Selenium WebDriver for .NET

Lombiq.Tests.UI The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Lombiq UI Testing Toolbox for Orchard Core: Web UI testing toolbox mostly for Orchard Core applications. Everything you need to do UI testing with Selenium for an Orchard app is here. See the project website for detailed documentation.

JDI.UIWeb

Framework for Web UI Automation Testing

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on WebDriverManager:

Repository Stars
rnwood/smtp4dev
smtp4dev - the fake smtp email server for development and testing
serenity-is/Serenity
Business Apps Made Simple with Asp.Net Core MVC / TypeScript
AutomateThePlanet/AutomateThePlanet-Learning-Series
Automate The Planet Series Source Code
Version Downloads Last updated
2.17.2 24,927 2/17/2024
2.17.1 1,063,935 8/9/2023
2.17.0 138,774 7/31/2023
2.16.3 113,225 6/26/2023
2.16.2 845,978 12/5/2022
2.16.1 174,045 11/11/2022
2.16.0 237,667 9/16/2022
2.15.0 174,281 8/16/2022
2.14.1 209,766 6/30/2022
2.14.0 11,159 6/28/2022
2.13.0 286,258 5/22/2022
2.12.4 278,484 4/5/2022
2.12.3 849,376 12/14/2021
2.12.2 330,981 10/26/2021
2.12.1 97,521 10/5/2021
2.12.0 46,439 9/16/2021
2.11.3 190,997 7/23/2021
2.11.2 27,187 6/29/2021
2.11.1 521,857 12/19/2020
2.11.0 200,046 9/21/2020
2.10.0 21,871 9/19/2020
2.9.3 59,498 8/2/2020
2.9.2 23,864 7/21/2020
2.9.1 120,597 4/5/2020
2.9.0 77,256 1/23/2020
2.8.0 3,999 1/20/2020
2.7.0 54,701 10/24/2019
2.6.0 275,320 9/1/2019
2.5.1 97,045 6/22/2019
2.5.0 2,916 5/22/2019
2.4.0 2,036 5/9/2019
2.3.1 4,416 4/10/2019
2.3.0 8,145 1/16/2019
2.2.8 1,223 1/9/2019
2.2.7 30,678 9/3/2018
2.2.6 39,526 7/8/2018
2.2.5 3,180 3/9/2018
2.2.4 2,858 11/25/2017
2.2.3 7,771 9/6/2017
2.2.2 1,314 9/5/2017
2.2.1 26,417 4/28/2017
2.2.0 1,422 3/7/2017
2.1.0 5,605 1/16/2017
2.0.1 1,239 1/14/2017
2.0.0 5,065 11/21/2016
1.3.0 1,184 11/11/2016
1.2.3 1,013 11/10/2016
1.2.2 1,205 10/30/2016
1.2.1 1,348 9/6/2016
1.2.0 1,170 8/29/2016
1.1.3 1,461 6/27/2016
1.1.2 1,487 6/24/2016
1.1.1 1,305 6/6/2016
1.1.0 1,424 5/27/2016
1.0.0 2,046 5/22/2016