上下文: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位); geckodriver 0.18.0
我很难在Windows服务计划任务中启动Firefox会话。我没有问题从C#exe交互式启动Selenium驱动的Firefox会话。
计划任务设置为“运行用户是否登录”,并选中“以最高权限运行”。
这个煮沸的exe中的部分代码:
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);
}
运行该代码一分钟后,我收到以下消息:
The HTTP request to the remote WebDriver server for URL http://localhost:51289/session timed out after 60 seconds.
有趣的是,根据任务管理器,geckodriver.exe在其命令行上有--port 51289
。
我一直在尝试FirefoxDriver
次调用的各种组合。没有按预期工作给出上述错误或
Unable to find a matching set of capabilities
这更没意义。我也尝试了几个不同版本的Firefox,但都无济于事。
是否存在某些Selenium,Firefox或者可能影响计划任务运行的Windows设置?任务启动,二进制运行,但Firefox没有启动。