So I am using Visual Studio and have installed Specflow Extension, Specflow Project and there is a Class Library project which contains a Method to Launch a Chrome Driver. The test I have written with Specflow is;
LaunchDriver launchDriver = new LaunchDriver() ;
[Given(@"I Launch a Chrome Driver")]
public void GivenILaunchAChromeDriver()
{
launchDriver.LaunchChrome();
}
The code of LaunchDriver Class is : public class LaunchDriver { public IWebDriver webDriver;
public void LaunchChrome()
{
string PathtoChromeExe = @"C:\Program Files (x86)\Google\Chrome\Application\";
webDriver = new ChromeDriver(PathtoChromeExe);
webDriver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(5);
webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
webDriver.Manage().Window.Maximize();
}
}
}
When I try to run this test via Test Explorer, I am seeing the test has failed due to following error
Launch Driver and Navigate to Google.com Duration: 378 ms
Message:
The file C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html
Stack Trace:
OpenQA.Selenium.DriverServiceNotFoundException: The file C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html
DriverService.ctor(String servicePath, Int32 port, String driverServiceExecutableName, Uri driverServiceDownloadUrl)
ChromiumDriverService.ctor(String executablePath, String executableFileName, Int32 port, Uri downloadUrl)
ChromeDriverService.ctor(String executablePath, String executableFileName, Int32 port)
ChromeDriverService.CreateDefaultService(String driverPath, String driverExecutableFileName)
ChromeDriverService.CreateDefaultService(String driverPath)
The Chrome driver which I need launching, its filename is chrome.exe in the path I have specified, but for some reason the Specflow or the System is looking for chromedriver.exe to launch which it cannot find. How do I configure my code to launch the chrome.exe and not chromedriver.exe?