How to set up selenium 3.0, getting error "The geckodriver.exe file does not exist..." in c# -


updated selenium in visual studio 3.0 , firefox 47.0 , i'm getting error when try use local webdriver mode: geckodriver.exe file not exist in current directory or in directory on path environment variable.

when i'm using remote mode (seleniumhub), works fine if uses firefox 45.0 version.

tried search examples, did not found c#, java , still not make work.

my webdriver setup:

 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}\" not implemented {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}\" not implemented {1} mode", configurationmanager.appsettings["webdriverbrowsercapabilities"].tolower(), configurationmanager.appsettings["webdrivermode"].tolower()));                         }                          capabilities.isjavascriptenabled = true;                         driver = new advancedremotewebdriver(huburl, capabilities);                         break;                     default:                         throw new notimplementedexception();                 } 

from selenium 3.0, have use geckodriver firefox browser.

download latest geckodriver here https://github.com/mozilla/geckodriver/releases

you have 2 options:

  1. enter geckodriver path in windows system environment variable path.
  2. or specify location of geckodriver.exe programmatically follows.

system.environment.setenvironmentvariable("webdriver.gecko.driver",@"/path/to/geckodriver.exe"

note: system restart may required if set path environment variable.

from firefox 47 onwards (excluding it), selenium uses geckodriver capabilities default. 47 , previous versions onwards, may need turn off capability selenium can use firefox built-in support used work these versions.

java version achieve same:

desiredcapabilities d = new desiredcapabilities(); d.setcapability("marionette", false);  // disable marionette. webdriver driver = new firefoxdriver(d); 

references:

  1. how 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

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -