selenium webdriver – FirefoxDriver Cannot start the driver service
Have an app that has been running without issue (or so Ive been told) for months, but as of a few weeks ago started failing. Looking at the logs, I see a lot of these errors
EXCEPTION: Error intializing Firefox driver. Error message: ‘Cannot
start the driver service on localhost:52022/‘;
WebDriverException stack: ‘OpenQA.Selenium.WebDriverException: Cannot
start the driver service on localhost:52022/ at
OpenQA.Selenium.DriverService.Start() at
OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command
commandToExecute) at
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters) at
OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities
desiredCapabilities) at
OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor
commandExecutor, ICapabilities desiredCapabilities) at … … .
The project is a console app that is using the Selenium project to try to connect to an external website but it seems it is having trouble just starting up. The code where this exception is caught is below.
this._logger = logger;
this._processLog = new List<string>();
FirefoxProfile profile = null;
FirefoxOptions options = null;
profile = new FirefoxProfile();
profile.SetPreference("browser.download.folderList", 2);
profile.SetPreference("browser.download.dir", downloadPath);
profile.SetPreference("browser.download.manager.alertOnEXEOpen", false);
profile.SetPreference("browser.download.manager.focusWhenStarting", false);
profile.SetPreference("browser.download.manager.closeWhenDone", true);
profile.SetPreference("browser.download.manager.showAlertOnComplete", false);
profile.SetPreference("browser.helperApps.alwaysAsk.force", false);
profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/json,text/csv");
profile.SetPreference("browser.download.manager.useWindow", false);
profile.SetPreference("browser.download.panel.shown", false);
options = new FirefoxOptions();
options.AddArguments("-headless");
options.AddArgument("no-sandbox");
options.Profile = profile;
try
{
this._driver = new FirefoxDriver(driverPath, options, TimeSpan.FromSeconds(180));
}
catch (WebDriverException ex)
{
string message = string.Format("Error intializing Firefox driver. Error message: '{0}'; WebDriverException stack: '{1}' ",
ex.Message, ex.ToString());
result.ProcessLog.Add(new LogMessage(LogLevel.EXCEPTION, message));
throw ex;
}
catch(Exception ex)
{
string message = string.Format("Error intializing Firefox driver. Error message: '{0}'; Exception stack: '{1}' ",
ex.Message, ex.ToString());
result.ProcessLog.Add(new LogMessage(LogLevel.EXCEPTION, message));
throw ex;
}
The computer where this process runs has the latest version of Firefox installed, however, the FireFox Selenium driver looks dated. Could there be a dependency issue?
Read more here: Source link