2016-11-17 3 views
4

비주얼 스튜디오에서 Selenium을 3.0으로, 파이어 폭스를 47.0으로 업데이트했으며 이제 시도 할 때이 오류가 발생합니다. 로컬 웹 드라이버 모드 사용 : geckodriver.exe 파일이 현재 디렉토리 또는 PATH 환경 변수의 디렉토리에 없습니다.Selenium 3.0을 설치하는 중 오류가 발생하는 경우 "geckodriver.exe 파일이 존재하지 않습니다 ..."C#

원격 모드 (seleniumhub)를 사용하면 firefox 45.0 버전을 사용하더라도 제대로 작동합니다.

몇 가지 예제를 찾으려고했지만 C#에서는 아무 것도 찾지 못했지만 java만으로는 작동하지 못했습니다.

내 webdriver 설정 : 셀레늄 3.0에서

switch (ConfigurationManager.AppSettings["WebDriverMode"].ToLower()) 
       { 
        case "local": 
         switch (ConfigurationManager.AppSettings["WebDriverBrowserCapabilities"].ToLower()) 
         { 
          case "firefox": 
           driver = new AdvancedFirefoxDriver(); 
           break; 
          case "ie": 
           driver = new AdvancedInternetExplorerDriver(); 
           break; 
          case "chrome": 
           driver = new AdvancedChromeDriver(); 
           break; 
          default: 
           throw new NotImplementedException(string.Format("WebDriverBrowserCapabilities of \"{0}\" is not implemented for {1} mode", ConfigurationManager.AppSettings["WebDriverBrowserCapabilities"].ToLower(), ConfigurationManager.AppSettings["WebDriverMode"].ToLower())); 
         } 

         break; 
        case "remote": 
         var huburl = new Uri(ConfigurationManager.AppSettings["SeleniumHubAddress"]); 
         DesiredCapabilities capabilities; 
         switch (ConfigurationManager.AppSettings["WebDriverBrowserCapabilities"].ToLower()) 
         { 
          case "firefox": 
           capabilities = DesiredCapabilities.Firefox(); 
           break; 
          case "ie": 
           capabilities = DesiredCapabilities.InternetExplorer(); 
           break; 
          case "chrome": 
           capabilities = DesiredCapabilities.Chrome(); 
           break; 
          default: 
           throw new NotImplementedException(string.Format("WebDriverBrowserCapabilities of \"{0}\" is not implemented for {1} mode", ConfigurationManager.AppSettings["WebDriverBrowserCapabilities"].ToLower(), ConfigurationManager.AppSettings["WebDriverMode"].ToLower())); 
         } 

         capabilities.IsJavaScriptEnabled = true; 
         driver = new AdvancedRemoteWebDriver(huburl, capabilities); 
         break; 
        default: 
         throw new NotImplementedException(); 
       } 

답변

4

, 당신은 파이어 폭스 브라우저의 geckodriver을 사용해야합니다. Windows 시스템 환경 변수 PATH

  1. 이 geckodriver 경로를 입력 :

    다운로드 여기 https://github.com/mozilla/geckodriver/releases

    의 최신 geckodriver 당신은 두 가지 옵션이 있습니다.

  2. 또는 다음과 같이 geckodriver.exe의 위치를 ​​프로그래밍 방식으로 지정하십시오.

System.Environment.SetEnvironmentVariable("webdriver.gecko.driver",@"/path/to/geckodriver.exe"

주 : 당신이 PATH 환경 변수를 설정하면 시스템을 다시 시작해야 할 수 있습니다.

Firefox 47 이후 버전 (제외)에서 Selenium은 기본적으로 geckodriver 기능을 사용합니다. 47 이전 버전에서 Selenium이 이전 버전과 같이 Firefox 내장 지원 기능을 사용할 수 있도록이 기능을 해제해야 할 수도 있습니다.

JAVA 버전이를 달성하기

DesiredCapabilities d = new DesiredCapabilities(); 
d.setCapability("marionette", false); // to disable marionette. 
WebDriver driver = new FirefoxDriver(d); 

참고 문헌 :

  1. how to set system properties in C#
  2. https://msdn.microsoft.com/en-us/library/z46c489x.aspx
  3. https://superuser.com/questions/317631/setting-path-in-windows-7-command-prompt
  4. https://stackoverflow.com/a/40466109/2575259
+1

"webdriver.gecko.driver" –

+1

@ NisimNaim, 감사합니다. 업데이트되었습니다. –