Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I have tried the following three options . I am using C#

DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability("chrome.binary", "pathtogooglechrome\chromedriver.exe");
_remoteWebDriver = new ScreenShotRemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
                    capabilities);

or

ChromeOptions options = new ChromeOptions();
options.BinaryLocation = "pathtogooglechrome\chromedriver.exe";
capabilities.SetCapability(ChromeOptions.Capability, options);
_remoteWebDriver = new ScreenShotRemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
                    capabilities);

or

System.Environment.SetEnvironmentVariable("webdriver.chrome.driver", "pathtogooglechrome\chromedriver.exe");
_remoteWebDriver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
                  DesiredCapabilities.Chrome());

After the SetEnviromentVariable if i try the following code i get path of the ChromeDriver.exe

string temp = System.Environment.GetEnvironmentVariable("webdriver.chrome.driver");

I always get the same error System.InvalidOperationException : The path to the driver executable must be set by the webdriver.chrome.driver system property I want know what i am doing wrong here, why path is not accepted?

Thank you in advance! If any alternative solution is available please let me know.

share|improve this question

1 Answer 1

From documentation:

BinaryLocation  
Gets or sets the location of the Chrome browser's binary executable file.

So the above excerpt plainly says that the BinaryLocation is the path for chrome.exe and not chromedriver.exe.

And chromedriver.exe path should be defined in the PATH environment variable.

So in your case the correct line would be:

options.BinaryLocation = @"pathtogooglechrome\chrome.exe"

Notice the @ in C# that will let you put un-escaped characters. Otherwise you would have needed \\ instead of \ etc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.