【问题标题】:c# selenium catch timeoutexception时间:2019-04-10 标签:c#seleniumcatchtimeoutexception
【发布时间】:2022-01-16 10:11:45
【问题描述】:

我有这个代码:

<code>

cNavigate = true;
while (cNavigate)
    {
     try
        {
         CrDriver.Navigate().GoToUrl(Url);
         cNavigate = false;
         }
      catch (WebDriverTimeoutException WebTime)
         {
          log.Info("Naviagte time out : "+WebTime.Message);
         }
    }
</code>

但似乎没有正确捕获超时。有人可以帮忙吗?

【问题讨论】:

  • 捕获所有异常,看看会捕获什么。也就是说,哪个异常类被捕获。然后你可以把它写到你的源代码中。
  • 通常是系统相关的。您可能会阻止您正在连接的站点或设置这样的时间,因为连接速度很慢。 var driver = new ChromeDriver(url, TimeSpan.FromMinutes(180));

标签: c# selenium google-chrome exception try-catch


【解决方案1】:

我终于记录下来了: 2021-12-15 05:26:18,615 INFO Browse2.Form1 - Other Exception time out : The HTTP request to the remote WebDriver server for URL http://localhost:55790/session/802f7027e123d0319fd98ea41e151413/url timed out after 60 seconds. System.Threading.Tasks.TaskCanceledException: Une tâche a été annulée. à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.TaskAwaiter1.GetResult() à OpenQA.Selenium.Remote.HttpCommandExecutor.&lt;MakeHttpRequest&gt;d__35.MoveNext() --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée --- à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) à System.Runtime.CompilerServices.TaskAwaiter1.GetResult() à OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) 似乎比抛出的异常与发送的不一样

【讨论】:

  • edit问题添加更多信息。不要张贴在答案框中。
猜你喜欢
  • 2016-04-19
  • 2018-07-04
  • 2019-06-02
  • 1970-01-01
  • 1970-01-01
  • 2013-05-26
  • 2015-02-10
  • 2013-06-03
  • 2018-09-10
相关资源
最近更新 更多