2014-12-13 44 views
1

我寫自動化系統,並完美地在本地主機工作,但是當我嘗試發佈它並上傳到服務器。我得到這個錯誤;無法定義硒鉻驅動程序路徑

unknown error: cannot find Chrome binary 
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) 

我日凌晨1十億確保這條道路的,這裏是我的代碼

  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); 

我的服務器是Windows的Windows NT 6.1 SP1 x86_64的 2008 R2企業版64位

+0

在你已經把chromedriver.exe的服務器? – 2014-12-13 09:41:33

+0

轉換爲「D:\ PathTo \」 – TeknobilSoft 2014-12-13 09:43:53

+0

@TeknoBilSoft,消息非常清晰:chromedriver.exe不在「D:\ PathTo」中。 – Jauch 2014-12-13 10:46:41

回答

2

您可以使用「標準位置」 鍍鉻的,是這樣的:

var options = new ChromeOptions(); 
// all of your 'options.AddArgument(...);' here 
driver = new ChromeDriver(options); //This will look for chrome in the default directory 

如果你需要通過鉻二進制在不同的目錄,你可以用這樣的方式:

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); 

經過一番研究,herehere,我很想說,你沒有ChromeDriver您的服務器上。

它應該在你的應用程序數據這樣的地方:

的Windows XP%HOMEPATH%\本地設置\應用數據\谷歌\鍍鉻\應用\的chrome.exe 的Windows Vista C:\用戶\%USERNAME% \ AppData \ Local \ Google \ Chrome \ Application \ chrome.exe

here下載ChromeDriver並將其安裝到您的服務器上。比第一個選項(沒有路徑)將起作用。

+2

是的,我添加; options.BinaryLocation = @「C:\ Program Files文件(x86)\ Google \ Chrome \ Application \ chrome.exe」;仍然沒有進展:\ – TeknobilSoft 2014-12-13 11:23:21

+0

這是默認位置。使用第一個選項,無需定義位置。 – Jauch 2014-12-13 11:25:35

+0

好的,我會更新我的答案。你是否下載過ChromeDriver服務器? – Jauch 2014-12-13 11:27:36

相關問題