I have come across a few people with the same issue that seemed to have solved the problem with System.addProperty(\"webdriver.chrome.driver\", \".../chromedriver.exe\");<
If you're using Atata and .Net Core, see this page: https://atata.io/getting-started/#dot-net-core-configuration
AtataContext.Configure()
.UseChrome()
.WithFixOfCommandExecutionDelay()
.WithLocalDriverPath()
.UseCulture("en-us")
.Build();
these are the lines you want to make sure you have:
.UseChrome()
.WithFixOfCommandExecutionDelay()
.WithLocalDriverPath()
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));
This is the error i see: OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable.
I resolved this problem by specifying the 'testsettings' argument in the command to run the unit tests.
E.g.
E:\Development\SampleProject\SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe" /testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx
I use "/testsettings:......\Local.Testsettings" because the Local.testsettings file is 4 levels higher than the level where I am executing this command. You should change it accordingly.
This is the command used in ccnet.config file
<exec>
<executable>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe</executable>
<baseDirectory>SampleProject.MvcWebApp\SampleProject.MvcWebApp.JavaScriptUnitTests\JavaScriptUnitTests\bin\Debug</baseDirectory>
<buildArgs>/testcontainer:JavaScriptUnitTests.dll /category:"JavaScriptUnitTests" /testsettings:..\..\..\Local.Testsettings /resultsfile:..\..\..\..\..\MsTestResults\SampleProject.MvcWebApp.JavaScript.Tests.trx</buildArgs>
<successExitCodes>0</successExitCodes>
</exec>
Install Selenium.WebDriver.ChromeDriver
from NuGet and then you can do the following:
IWebDriver driver = new ChromeDriver(Environment.CurrentDirectory);
I found that although the Selenium.WebDriver.ChromeDriver NuGet package had been downloaded and consequently the chromedriver.exe file was being copied into the bin folder at compile time, additionally it needed to be marked as a deployment item (because it is a unit test that copied-into/run-from the TestResults folder) - i.e.
[DeploymentItem(@"chromedriver.exe")]
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);
}