Updated selenium in visual studio to 3.0 and firefox to 47.0 and now I'm getting this error when I try to use local webdriver mode: The geckodriver.exe file does not exist in the current directory or in a directory on the PATH environment variable.
When I'm using remote mode (seleniumhub), it works fine even if it uses firefox 45.0 version.
Tried to search for some examples, but did not found anything for c#, only for java and still could not make it 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}\" 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();
}
From selenium 3.0, you have to use the
geckodriver
for Firefox browser.download the latest geckodriver from here https://github.com/mozilla/geckodriver/releases
You have two options:
PATH
.System.Environment.SetEnvironmentVariable("webdriver.gecko.driver",@"/path/to/geckodriver.exe"
Note: System restart may be required if you set PATH environment variable.
From Firefox 47 onwards (Excluding it), Selenium uses geckodriver capabilities by default. For 47 and previous versions onwards, you may need to turn off this capability so that Selenium can use Firefox built-in support like we used to work with these versions.
JAVA version to achieve the same:
References: