首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Selenium错误-对远程WebDriver的HTTP请求在60秒后超时

Selenium错误-对远程WebDriver的HTTP请求在60秒后超时
EN

Stack Overflow用户
提问于 2014-03-11 18:13:22
回答 15查看 117.9K关注 0票数 92

我使用Selenium已经有几个月了,我们正在使用它来自动化一些内部测试过程。脚本一直都通过得很好。我最近使用FF 27.01升级到了C# 2.40.0WebDriver,我们的脚本现在在随机的地方失败了,错误如下。

[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();

令人恼火的是,尝试解决这个问题被证明是困难的,就像我在本地机器上运行测试一样,在debug中通过。此外,如果我在运行测试的构建机器上通过NUNIT运行器运行它,它也会通过。它似乎只在使用Teamcity时作为自动构建运行过程的一部分失败。正如我所说的,这已经运行了几个月,唯一改变的是selenium webdriver工具包。

我以前在调试时遇到过这个问题,当调用Click()代码行时,火狐似乎被锁住了,只有停止测试才能让火狐继续。这里有很多建议,包括修改webdriver源代码?如果其他人能提供任何建议,如果可能的话,我不想走这条路。

EN

回答 15

Stack Overflow用户

发布于 2016-09-03 03:57:54

我在使用Chrome驱动程序(v2.23) /通过TeamCity运行测试时也遇到了类似的问题。我可以通过在Chrome选项中添加"no-sandbox“标记来解决这个问题:

var options = new ChromeOptions();
options.AddArgument("no-sandbox");

我不确定FF驱动程序是否有类似的选项。据我所知,这个问题与TeamCity在SYSTEM帐户下运行Selenium有关。

票数 33
EN

Stack Overflow用户

发布于 2015-05-08 12:22:12

new FirefoxDriver(new FirefoxBinary(),new FirefoxProfile(),TimeSpan.FromSeconds(180));

使用上面的代码行启动浏览器。这对我很管用。

票数 22
EN

Stack Overflow用户

发布于 2019-11-05 08:50:32

在Firefox上也有同样的问题。我切换到Chrome的选项,从那以后一切都很好。

ChromeOptions options = new ChromeOptions();
options.AddArgument("no-sandbox");

ChromeDriver driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromMinutes(3));
driver.Manage().Timeouts().PageLoad.Add(System.TimeSpan.FromSeconds(30));
票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22322596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档