Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChromeDriver does not exist in Selenium WebDriver C# test script

I have come across a few people with the same issue that seemed to have solved the problem with System.addProperty("webdriver.chrome.driver", ".../chromedriver.exe"); before instantiating the driver.

I have had little luck with this and am still getting the error that the file .../bin/Debug/chromedriver.exe does not exist.

Has anyone had any luck getting this to run without putting it in the bin folder?

Example code:

System.Environment.SetEnvironmentVariable("webdriver.chrome.driver", @"c:\path\to\driver\chromedriver.exe"); BrowserDriver = new ChromeDriver(); 
like image 723
Highstead Avatar asked Jan 31 '12 23:01

Highstead


People also ask

Do we need to install Chromedriver for Selenium?

As Google Chrome dominates the browser market, the use of a ChromeDriver becomes a must. Selenium WebDriver uses the ChromeDriver to communicate test scripts with Google Chrome.

What is Webdrivermanager Chromedriver () setup ()?

chromedriver(). setup: checks for the latest version of the specified WebDriver binary. If the binaries are not present on the machine, then it will download the WebDriver binaries. Next, it instantiates the Selenium WebDriver instance with the ChromeDriver.


2 Answers

Since you're using C#, you should use the constructor overload for ChromeDriver that allows you to specify the path to the directory containing chromedriver.exe. To wit:

IWebDriver driver = new ChromeDriver(@"C:\my\path\to\chromedriver\directory"); 
like image 142
JimEvans Avatar answered Sep 19 '22 23:09

JimEvans


Old question, new answer (for what it's worth): just install the Nuget package Selenium.WebDriver.ChromeDriver. Chromedriver.exe will be in the directory bin/debug on the next build.

3rd party edit 2017-09

On this github page jsakamoto/nupkg-selenium-webdriver-chromedriver/ that after running Install-Package Selenium.WebDriver -Version 3.5.2 the chromedriver(.exe) lies below this folder

" {solution folder} /packages/Selenium.WebDriver.ChromeDriver. {ver} /driver/ {platform}"

like image 35
Mcanic Avatar answered Sep 19 '22 23:09

Mcanic