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:
- enter geckodriver path in windows system environment variable
path
. - 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:
Comments
Post a Comment