• <legend id='K62Ee'><style id='K62Ee'><dir id='K62Ee'><q id='K62Ee'></q></dir></style></legend>

      <bdo id='K62Ee'></bdo><ul id='K62Ee'></ul>

    <small id='K62Ee'></small><noframes id='K62Ee'>

    <i id='K62Ee'><tr id='K62Ee'><dt id='K62Ee'><q id='K62Ee'><span id='K62Ee'><b id='K62Ee'><form id='K62Ee'><ins id='K62Ee'></ins><ul id='K62Ee'></ul><sub id='K62Ee'></sub></form><legend id='K62Ee'></legend><bdo id='K62Ee'><pre id='K62Ee'><center id='K62Ee'></center></pre></bdo></b><th id='K62Ee'></th></span></q></dt></tr></i><div id='K62Ee'><tfoot id='K62Ee'></tfoot><dl id='K62Ee'><fieldset id='K62Ee'></fieldset></dl></div>
    1. <tfoot id='K62Ee'></tfoot>

        Selenium WebDriver - 如何使用 C# 设置页面加载超时

        时间:2023-09-13
        • <bdo id='vmxA1'></bdo><ul id='vmxA1'></ul>
          <tfoot id='vmxA1'></tfoot>

            <legend id='vmxA1'><style id='vmxA1'><dir id='vmxA1'><q id='vmxA1'></q></dir></style></legend>
              <tbody id='vmxA1'></tbody>

            1. <i id='vmxA1'><tr id='vmxA1'><dt id='vmxA1'><q id='vmxA1'><span id='vmxA1'><b id='vmxA1'><form id='vmxA1'><ins id='vmxA1'></ins><ul id='vmxA1'></ul><sub id='vmxA1'></sub></form><legend id='vmxA1'></legend><bdo id='vmxA1'><pre id='vmxA1'><center id='vmxA1'></center></pre></bdo></b><th id='vmxA1'></th></span></q></dt></tr></i><div id='vmxA1'><tfoot id='vmxA1'></tfoot><dl id='vmxA1'><fieldset id='vmxA1'></fieldset></dl></div>

              <small id='vmxA1'></small><noframes id='vmxA1'>

                  本文介绍了Selenium WebDriver - 如何使用 C# 设置页面加载超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Selenium 2.20 WebDriver 创建和管理带有 C# 的 firefox 浏览器.要访问一个页面,我使用以下代码,在访问 URL 之前设置驱动程序超时:

                  I am using Selenium 2.20 WebDriver to create and manage a firefox browser with C#. To visit a page, i use the following code, setting the driver timeouts before visiting the URL:

                  driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); // Set implicit wait timeouts to 5 secs
                  driver.Manage().Timeouts().SetScriptTimeout(new TimeSpan(0, 0, 0, 5));  // Set script timeouts to 5 secs
                  driver.Navigate().GoToUrl(myUrl);   // Goto page url
                  

                  问题是有时页面加载需要很长时间,而且使用 selenium WebDriver 加载页面的默认超时似乎是 30 秒,这太长了.而且我不相信我设置的超时适用于使用 GoToUrl() 方法加载页面.

                  The problem is that sometimes pages take forever to load, and it appears that the default timeout for a page to load using the selenium WebDriver is 30 seconds, which is too long. And i don't believe the timeouts i am setting apply to the loading of a page using the GoToUrl() method.

                  所以我试图弄清楚如何设置页面加载超时,但是,我找不到任何实际有效的属性或方法.当我点击一个元素时,默认的 30 秒超时似乎也适用.

                  So I am trying to figure out how to set a timeout for a page to load, however, i cannot find any property or method that actually works. The default 30 second timeout also seems to apply to when i click an element.

                  有没有办法将页面加载超时设置为特定值,这样当我调用 GoToUrl() 方法时,它只会等待我指定的时间才能继续?

                  Is there a way to set the page load timeout to a specific value so that when i call the GoToUrl() method it will only wait my specified time before continuing?

                  推荐答案

                  driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(5);
                  

                  注意:driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(5)) 现已弃用.

                  这篇关于Selenium WebDriver - 如何使用 C# 设置页面加载超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:升级到 3.9 版后无法启动 Selenium IE 驱动程序 下一篇:.NET 是否有 HtmlUnitDriver?

                  相关文章

                  <tfoot id='2PrY8'></tfoot>
                  • <bdo id='2PrY8'></bdo><ul id='2PrY8'></ul>
                1. <legend id='2PrY8'><style id='2PrY8'><dir id='2PrY8'><q id='2PrY8'></q></dir></style></legend>

                    <small id='2PrY8'></small><noframes id='2PrY8'>

                    1. <i id='2PrY8'><tr id='2PrY8'><dt id='2PrY8'><q id='2PrY8'><span id='2PrY8'><b id='2PrY8'><form id='2PrY8'><ins id='2PrY8'></ins><ul id='2PrY8'></ul><sub id='2PrY8'></sub></form><legend id='2PrY8'></legend><bdo id='2PrY8'><pre id='2PrY8'><center id='2PrY8'></center></pre></bdo></b><th id='2PrY8'></th></span></q></dt></tr></i><div id='2PrY8'><tfoot id='2PrY8'></tfoot><dl id='2PrY8'><fieldset id='2PrY8'></fieldset></dl></div>