I have added the WebDriver.ChromeDriver nuget package to my solution, which contains the ChromeDriver.exe file, required for Selenium WebDriver to run automated tests using Chrome. Looking at the package contents, it just contains the file following file:
tools\chromedriver.exe
What this is supposed to do is add this folder to the PATH environment variable so that chromedriver.exe is accessible via the following code (this is in a UnitTest project using MSTest):
[TestMethod]
public void LaunchWebsite_Chrome()
{
// create ChromeDriver - this should work if chromedriver.exe
// is known to the environment PATH variable
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://localhost/");
}
However, I am still getting the following exception:
The 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://code.google.com/p/chromium/downloads/list.
Looking at the nuget documentation, it suggests that anything in the tools folder of the nuget package will get added to the PATH environment variable automatically:
http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package: The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.
However, this doesn't seem to be working. I have even run echo %PATH%
on the command line and it doesn't show my tools folder as registered.
What am I doing wrong?
Users provided relevant link to confirm that, "YES" a full Chrome installation is needed in addition to the actual chromedriver.
Export your code as jar without the chromedriver. Create a folder ChromeDriver. Place your chromedriver.exe in this folder. Place ChromeDriver folder along with your jar.
I wouldn't bother with the NuGet package for this, simply because this is not a class library - which is technically, what NuGet is all about. ChromeDriver has also been updated many times since that release.
Anyway, I would say that I have just done the same thing to see what the issue is:
You are probably falling down on point 4. That setting is set to Do not copy by default.
The Nuget package will place the driver.exe file in {buildconfiguration}/ To tell it to look in the root of the application, pass a "." when creating a new instance of the driver.
IWebDriver driver = new ChromeDriver(".");
I had similar problem solved it by these 3 steps
1.Goto google chrome drivers official site https://sites.google.com/a/chromium.org/chromedriver/downloads download and unpack
2.Goto Visual Studio solution explorer click add -> existing file -> select chrome driver
3.Right click on chrome driver in VS and select properties set it to always copy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With