Context: Microsoft Azure / Windows 2012 R2; C#; Selenium.Webdriver 3.4.0; Selenium.Support 3.4.0; Selenium.WebDriver.GeckoDriver.Win64 0.18.0; Firefox 54.0.1 (64-bit); geckodriver 0.18.0
I'm having enormous difficulty getting the Firefox session to launch inside a Windows Service Scheduled Task. Chrome will do it but I have reasons for using Firefox. I have no problem launching a Selenium-driven Firefox session from a C# exe interactively.
The Scheduled Task is set to "Run whether user is logged on or not", and "Run with highest privilege" is checked.
Part of the code:
FirefoxProfile fp = new FirefoxProfile(@"C:\web\FirefoxProfiles\Thingo"); fp.AcceptUntrustedCertificates = true; FirefoxOptions fo = new FirefoxOptions(); fo.Profile = fp; fo.LogLevel = FirefoxDriverLogLevel.Debug; fo.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe"; var ts = TimeSpan.FromMinutes(1); IWebDriver driver = null; try { driver = new FirefoxDriver(fo); } catch (Exception E) { Console.WriteLine(E.Message); Environment.Exit(255); }
After a minute of running that code I get the following Message:
The HTTP request to the remote WebDriver server for URL http://localhost:51289/session timed out after 60 seconds.
Interestingly, according to Task Manager, geckodriver.exe has --port 51289
on its command line.
I've been trying various combinations of Selenium invocations. None work as expected giving the above error or
Unable to find a matching set of capabilities
which makes even less sense. I've also tried a couple of different versions of Firefox, all to no avail.
Is there some Selenium, Firefox or, for that matter, Windows setting that might be affecting the running of the scheduled task? The task launches, and the binary runs, but Firefox is not launched.
capabilities.setCapability("marionette", false);
- driver = new FirefoxDriver(capabilities);
+ driver = new FirefoxDriver();