将 Visual Studio 中的 selenium 更新为 3.0,将 firefox 更新为 47.0,现在当我尝试使用本地 webdriver 模式时出现此错误:当前目录或 PATH 环境变量上的目录中不存在 geckodriver.exe 文件。
当我使用远程模式(seleniumhub)时,即使它使用 Firefox 45.0 版本也可以正常工作。
试图搜索一些示例,但没有找到 c# 的任何内容,仅适用于 java 并且仍然无法使其工作。
我的网络驱动程序设置:
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();
}