With the announcement from Microsoft to stop supporting Coded UI tests, I’m back in Selenium land.
To get it back in my fingers, I started to write a first simple Selenium test:
But although this test looked quite simple, it failed with the following exception:
Test Name: TestMethod1
Test FullName: SeleniumTestProject.UnitTest1.TestMethod1
Test Source: C:\projects\test\SeleniumTestProject\UnitTest1.cs : line 10
Test Outcome: Failed
Test Duration: 0:00:00,2912324
Result StackTrace:
at OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)
at OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService()
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at SeleniumTestProject.UnitTest1.TestMethod1() in C:\projects\test\SeleniumTestProject\UnitTest1.cs:line 15
Result Message:
Test method SeleniumTestProject.UnitTest1.TestMethod1 threw exception:
OpenQA.Selenium.DriverServiceNotFoundException: 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.
The exception was easy to understand, I needed the chromedriver.exe to spin up a chrome instance. I could follow the suggestions in the exception and download it from http://chromedriver.storage.googleapis.com/index.html. A simpler alternative is adding the Selenium.Chrome.WebDriver NuGet package to your project.
This package does all the work for you: tt installs Chrome Driver(Win32) for Selenium WebDriver into your Unit Test Project and copies the "chromedriver.exe" to the bin folder when building your project.