【发布时间】:2013-03-05 19:50:03
【问题描述】:
我使用 WebDriver 的 .NET 绑定通过 Grid2 同时运行测试。单独运行测试是没有问题的,但是通过Grid运行多个测试时,偶尔会出现以下错误,而一旦出现,通常多个测试失败原因相同:
无法在 45000 毫秒内绑定到锁定端口 7054 构建信息: 版本:'2.29.0',修订:'58258c3',时间:'2013-01-17 22:46:35' 系统信息: os.name: 'Windows Server 2008 R2', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_11' 驱动信息: driver.version: FirefoxDriver
我们已将问题的根源追溯到我们创建 RemoteWebDriver 实例的位置,如下所示:
var desiredCapabilites = new DesiredCapabilities();
desiredCapabilites.SetCapability(CapabilityType.BrowserName, "firefox");
desiredCapabilites.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
desiredCapabilites.SetCapability(CapabilityType.Version, "14.0.1");
try { _driver = new RemoteWebDriver(new Uri("http://qwautomation:4444/wd/hub"), desiredCapabilites, TimeSpan.FromSeconds(180.0)); }
catch (Exception ex) { Notes.Add("AUTOMATION ERROR: This error originates from MasterSetup.cs (line 47)"); Notes.Add("AUTOMATION ERROR: " + ex.Message); Exception("AUTOMATION ERROR: This error originates from MasterSetup.cs (line 47)"); }
其中,qwautomation 是我们的 Grid Hub 所在的机器。我的假设是集线器正在将测试分派到端口上已经包含 FireFox 实例的节点,或者 JVM 没有正确处理会话(因为我可以在节点机器中看到带有 WebDriver 会话 ID 的文件夹临时文件夹)。 我已经为节点和集线器编写了配置文件,我将在下面发布。如果无法绑定到 FireFox 端口,我不知道是否有办法将测试“排队”。
集线器
{
"port": 4444,
"newSessionWaitTimeout": 30000,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 300000,
"browserTimeout": 0,
"maxSession": 1
}
节点
{
"capabilities":
[
{
"browserName":"firefox",
"maxInstances":1
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":180000,
"maxSession":5,
"hubPort":4444,
"hubHost":"qwautomation"
}
}
编辑:我已经从 DesiredCapabilities 对象中删除了“版本”功能,并且在几次测试运行后没有看到错误表面。我不知道这是否是一个实际的解决方案,但它似乎至少降低了异常的风险。
【问题讨论】:
-
杀死所有firefox会话然后尝试..如果它不起作用卸载firefox并再次安装。
-
我已经重新安装了多个版本的 Firefox,但这不是解决办法。我正在寻找一个长期的解决方案,因为在发生此问题时必须手动终止会话或重新安装 FF 是不切实际的,因为我们有 24/7 运行的测试。
-
在开始测试之前杀死所有 java 进程。
-
它运行的是什么 exact 版本的 Firefox?
-
我们在 6 个节点上运行 14.0.1,在其他 3 个节点上运行 17.0.1。我们有针对目标节点的代码设置,但我已经看到这个问题出现在我尝试过的所有 FF 版本上,甚至早于 14。切换到 Chrome 已经消除了这个问题,但我希望能够在 FF 上运行测试。我想知道这是否是 FirefoxDriver 的问题,因为它似乎没有释放端口 7055 的锁定。
标签: c# automation webdriver selenium-webdriver