Reputation: 9305
I wrote a unit test using Selenium. The Unit test-class has a few (working) Unit tests. The constructor looks like this:
private IWebDriver _chrome;
public SeleniumTest()
{
_chrome = new ChromeDriver();
}
When I run one of the UnitTests inside that Test class using the Test Exporer everything works fine.
But when I create an ordered test that contains the same unit test I receive an error when trying to initiate the ChromeDriver:
OpenQA.Selenium.DriverServiceNotFoundException was unhandled by user code
HResult=-2146233088
Message=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://chromedriver.storage.googleapis.com/index.html.
Source=WebDriver
StackTrace:
bei OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)
bei OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService()
bei OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
bei OpenQA.Selenium.Chrome.ChromeDriver..ctor()
bei MyTest.SeleniumTest..ctor() in C:\dev\myTest\SeleniumTest.cs:Zeile 27.
I added Selenium (and Chrome) using NuGet to that project
UPDATE: chromedriver.exe is inside the BIN-directory of the project
Upvotes: 1
Views: 1342
Reputation: 9305
The problem is that ordered Tests create their own directories and run the code from there. They look like this:
C:\dev\myApp\MyTest\TestResults\MachineName 2016-06-15 15_26_39\Out
And inside this directory there is no chromedriver.exe
I solved this by using the DeploymentItem
- Attribute. This attribute copies files from the bin-directory to the Out-directory before creating an instance of the class. So the class-Attributes looked like this:
[TestClass]
[DeploymentItem("chromedriver.exe")]
After that the orderedTest runs without error
Upvotes: 3
Reputation: 4336
It cannot find the chromedriver executable. You should add the path to your chromedriver.exe in your PATH environment variable as it says in the execption message:
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://chromedriver.storage.googleapis.com/index.html.
Upvotes: 0