.NET:如何找出我的Selenium ChromeDriver构造函数为何超时?

时间:2019-12-19 21:14:03

标签: selenium selenium-webdriver selenium-chromedriver

我有一个C#项目,该项目实现了多个Selenium.WebDriver浏览器测试。测试通过Selenium.WebDriver.ChromeDriver中提供的ChromeDriver类针对Google Chrome。

测试在שCI环境中通过绿色测试,但是当我在本地运行它们(从Visual Studio 2019在调试模式下)时,会发生以下情况:

  1. 我看到Google Chrome在“远程控制模式”下打开。
  2. Chrome浏览器显示空白页(URL说“ data;”。)
  3. 运行冻结在我称为ChromeDriver构造函数的行上。
  4. 60秒后,将引发以下堆栈跟踪异常:
OpenQA.Selenium.WebDriverException
  HResult=0x80131500
  Message=The HTTP request to the remote WebDriver server for URL http://localhost:27556/session timed out after 60 seconds.
  Source=WebDriver
  StackTrace:
   at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
   at MyProject.Infra.WebDriver.WebDriverFactory.CreateWebDriver() in C:\MyProject\Infra\WebDriver\WebDriverFactory.cs:line 53
   at MyProject.Infra.WindsorContainer.WindsorInstaller.<Install>b__2_2() in C:\MyProject\Infra\WindsorContainer\WindsorInstaller.cs:line 62
   at Castle.MicroKernel.Registration.ComponentRegistration`1.<>c__DisplayClass83_0`1.<UsingFactoryMethod>b__0(IKernel k, ComponentModel m, CreationContext c)
   at Castle.MicroKernel.ComponentActivator.FactoryMethodActivator`1.Instantiate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
   at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver)

Inner Exception 1:
WebException: The operation has timed out

我的问题是-如何确定对远程WedDriver服务器的请求为何超时?是否可以启用调试或跟踪日志?还是可以进入ChromeDriver构造函数来检查其内部工作原理?怎么样?

请注意:我不包含用于设置ChromeDriver的特定代码,因为我受到代码所有者的某些代码安全性限制。我的问题是关于调试一般情况的通用过程或工具。谢谢。

0 个答案:

没有答案