Reputation: 167
I write automation system and perfectly works in localhost, but when i try to publish it and upload to server. I got this error;
unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
And I am 1 billion sure of this path, here is my code
var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
var options = new ChromeOptions();
var driverPath = Path.Combine(outPutDirectory, "ChromeDriverInThisFolder\\");
string driver_path = new Uri(driverPath).LocalPath;
driver = new ChromeDriver(driver_path, options);
My server is windows Windows NT 6.1 SP1 x86_64 2008 R2 Enterprise 64 bit
Upvotes: 1
Views: 6470
Reputation: 1518
You can use the "standard location" of chrome, this way:
var options = new ChromeOptions();
// all of your 'options.AddArgument(...);' here
driver = new ChromeDriver(options); //This will look for chrome in the default directory
If you need to pass a chrome binary in a different directory you can use this way:
var options = new ChromeOptions();
// all of your 'options.AddArgument(...);' here
options.setBinary("pathToYourOtherBinary"); //This is for CHROME binary, not ChromeDriver binary
driver = new ChromeDriver(options);
After some research, here and here, I'm tempted to say that you don't have ChromeDriver on your server.
It should be somewhere on your AppData like this:
Windows XP %HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe Windows Vista C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
Donwload ChromeDriver from here and install it on your server. Than the first option (whithout the path) will work.
Upvotes: 2