15

I get this error when I try to run my test in Chrome:

Initialization method AutomationUsingSelenium.SmuladorChrome.MyTestInitialize threw exception. OpenQA.Selenium.DriverServiceNotFoundException: OpenQA.Selenium.DriverServiceNotFoundException

What is the cause?

7
  • Did you try giving chromedriver path? Commented May 18, 2012 at 14:43
  • Yes, but not work:System.Environment.SetEnvironmentVariable("webdriver.chrome.driver", "C:\\..\\Drivers\\chromedriver.exe"); IWebDriver drive = new ChromeDriver(); Commented May 18, 2012 at 14:52
  • Can you try the second option mentioned in this qn stackoverflow.com/questions/10650360/… Commented May 18, 2012 at 14:57
  • WebDriver does not requires Selenium Server to be running. Commented May 18, 2012 at 15:07
  • 1
    Ah, my bad. I was thnking abt remote webdriver.. Commented May 18, 2012 at 15:10

4 Answers 4

15

Finally I resolved my issue as follows:

1) I copied chromedriver.exe in Chrome directory link, but you can put it in any directory. I decided to put it here.

2) I Initialized a new instance of the ChromeDriver class using the specified // path to the directory containing ChromeDriver.exe

My code:

IWebDriver drive = new ChromeDriver
("C:\\Documents and Settings\\...\\ApplicationData\\Google\\Chrome\\Application");

And it works just perfect. Thanks All.

Sign up to request clarification or add additional context in comments.

Comments

8

Install Selenium.Chrome.WebDriver NuGet package to the project and you will not get the error again.

In Visual Studio, right click the Project, click Manage NuGet Packages... , Search for Selenium.Chrome.WebDriver and click install.

Enjoy Selenium.

1 Comment

This is the best/ easiest solution for VS users- it includes everything you need; no need to worry about setting the paths.
6

Lets assume chromedriver.exe is present in below path: G:\Selenium_Csharp\Jar\chromedriver_win32\chromedriver.exe

To execute your test in Chrome set the path to the directory/folder containing chromedriver.exe without selecting chromedriver.exe file name.

driver = new ChromeDriver("G:\\Selenium_Csharp\\Jar\\chromedriver_win32");

driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();

OR

driver = new ChromeDriver(@"G:\Selenium_Csharp\\Jar\\chromedriver_win32");

driver.Url ="http://www.gmail.com";
driver.Manage().Window.Maximize();

Comments

0

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>

1 Comment

I didn't find this answer helpful because you give no explanation of what's being fixed or how to create a testsettings file. After lots of research I determined that the testsettings file has to have "Enable deployment" disabled which requires toggling that setting in the Test Settings UI. The basic issue is that during deployment, MSTest only copies dll's, config's but not exe's.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.