ChromeDriver does not exist in Selenium WebDriver C# test script
Since you're using C#, you should use the constructor overload for ChromeDriver that allows you to specify the path to the directory containing chromedriver.exe. To wit:
IWebDriver driver = new ChromeDriver(@"C:\my\path\to\chromedriver\directory");
Old question, new answer (for what it's worth): just install the Nuget package Selenium.WebDriver.ChromeDriver. Chromedriver.exe will be in the directory bin/debug on the next build.
3rd party edit 2017-09
On this github page jsakamoto/nupkg-selenium-webdriver-chromedriver/ that after running Install-Package Selenium.WebDriver -Version 3.5.2
the chromedriver(.exe) lies below this folder
" {solution folder} /packages/Selenium.WebDriver.ChromeDriver. {ver} /driver/ {platform}"
Could this be because NuGet packages are being loaded from a global place instead of the packages folder of the .NET Framework projects. This worked for me:
IWebDriver driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
Install Selenium.WebDriver.ChromeDriver
from NuGet and then you can do the following:
IWebDriver driver = new ChromeDriver(Environment.CurrentDirectory);
you may have enum for your all drivers :
public enum Drivers
{
Chrome,
Firefox,
Safari,
Edge,
IE
}
public static IWebDriver GetDriver(Drivers driver)
{
outPutDirectory -> is a location where all supporting dlls and files are copied when you build the solution. example : C:\Users\Mike\source\repos\Automation\Automation\bin\Debug
var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// below is my location where I copied all drivers like chromedriver.exe
relativePath -> is a one of folder being copied when you build soltuion exampple : C:\Users\Mike\source\repos\Automation\Automation\bin\Debug\BrowserDriver
var relativePath = @"..\..\bin\Debug\BrowserDriver";
//So 'chromeDriverPath' will give you exact location of your driver no matter which machine or PC you are running Automation
var chromeDriverPath = Path.GetFullPath(Path.Combine(outPutDirectory,relativePath));
// return this driver , just debug this code and check the "outPutDirectory" path
return new ChromeDriver(chromeDriverPath);
}