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\");<
This was a challenging one to isolate - the clue is in the nuget source which contains Selenium.WebDriver.ChromeDriver.targets - the targets requires an explicit property assignment so chromedriver.exe
is never copied to vstest.console
deployment directory. Here is the fix to add to your CSPROJ file:
PublishChromeDriver
Property in CSPROJ <PropertyGroup>
<AssemblyName>MyUX.Tests</AssemblyName>
<!-- ... -->
<PublishChromeDriver>True</PublishChromeDriver>
</PropertyGroup>
After this property is defined, a copy of chromedriver.exe
will be copied to /bin
for vstest.console
. This fixes the error we were receiving:
chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html
<Target Name="CopyChromeDriverToBin" BeforeTargets="AfterBuild">
<Copy SourceFiles="$(ChromeDriverSrcPath)" DestinationFiles="$(TargetDir)$(ChromeDriverName)" SkipUnchangedFiles="true">
</Copy>
</Target>
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.
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}"
I've installed the nuget package in my c# console application and after build there was no 'chromedriver.exe' in bin/Debug folder. So I manually downloaded the chromedriver for my version of chrome and copied it to the directory manually and then it worked.
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");