【发布时间】:2014-04-14 21:07:27
【问题描述】:
我已经使用 Selenium 几个月了,我们用它来自动化我们的一些内部测试流程。脚本一直很好。我最近使用 FF 27.01 升级到 C# 2.40.0 webdriver,我们的脚本现在在随机位置失败并出现以下错误。
[Portal.SmokeTest.SmokeRunTest.Booking] TearDown method failed. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/element timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
TearDown : OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/window timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
[09:01:20]
[Portal.SmokeTest.SmokeRunTest.Booking] TearDown method failed. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/element timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
TearDown : OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/window timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
at OpenQA.Selenium.Support.UI.DefaultWait`1.PropagateExceptionIfNotIgnored(Exception e)
at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
at Portal.Test.Helpers.Process_Bookings.OpenBookings.SelectBooking(String bookingnumber)
at Portal.SmokeTest.SmokeRunTest.Booking() in d:\TeamCityAgent\work\dac1dcea7f2e80df\SmokeTests\SmokeRunTest.cs:line 68
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--TearDown
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.Close()
at Portal.Test.Helpers.Setup.CloseWebdriver()
at Portal.SmokeTest.SmokeRunTest.TearDown() in d:\TeamCityAgent\work\dac1dcea7f2e80df\SmokeTests\SmokeRunTest.cs:line 162
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
我设法追踪到一行代码的最新错误:
_setup.driver.FindElement(By.XPath("//button[@class='buttonSmall lockBookingButton']")).Click();
令人讨厌的是,试图解决问题被证明是困难的,就好像我在本地机器上运行测试一样,在调试时它通过了。此外,如果我通过构建机器上的 NUNIT 运行程序运行它,我正在运行测试,它也通过了。在使用 Teamcity 时,它似乎只是作为我们自动构建运行过程的一部分而失败。就像我说的,这几个月前一直运行良好,唯一改变的是 selenium webdriver 套件。
我之前遇到过这个问题,在调试时,当调用Click() 代码行时,Firefox 似乎锁定了,只有停止测试才能让 Firefox 继续运行。这里有很多建议,包括修改 webdriver 源?如果其他人可以提供任何建议,我希望尽可能不走那条路。
【问题讨论】:
-
我们在几个使用此设置的独立项目中遇到了完全相同的问题,但仍然没有解决方法。我们最好的选择是降级到旧版本的 WebDriver 和 Firefox 程序集。我们也不知道这种行为是由 WebDriver 还是 Firefox 引起的。
标签: c# selenium selenium-webdriver nunit teamcity