• <bdo id='jSVcq'></bdo><ul id='jSVcq'></ul>
  1. <small id='jSVcq'></small><noframes id='jSVcq'>

      <tfoot id='jSVcq'></tfoot>

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

      Selenium .set_script_timeout(n) 有什么作用,它与 driver.set_page_loa

      时间:2023-07-04
      <i id='0Y1Up'><tr id='0Y1Up'><dt id='0Y1Up'><q id='0Y1Up'><span id='0Y1Up'><b id='0Y1Up'><form id='0Y1Up'><ins id='0Y1Up'></ins><ul id='0Y1Up'></ul><sub id='0Y1Up'></sub></form><legend id='0Y1Up'></legend><bdo id='0Y1Up'><pre id='0Y1Up'><center id='0Y1Up'></center></pre></bdo></b><th id='0Y1Up'></th></span></q></dt></tr></i><div id='0Y1Up'><tfoot id='0Y1Up'></tfoot><dl id='0Y1Up'><fieldset id='0Y1Up'></fieldset></dl></div>

      1. <legend id='0Y1Up'><style id='0Y1Up'><dir id='0Y1Up'><q id='0Y1Up'></q></dir></style></legend>

        • <bdo id='0Y1Up'></bdo><ul id='0Y1Up'></ul>

          <tfoot id='0Y1Up'></tfoot>
              • <small id='0Y1Up'></small><noframes id='0Y1Up'>

                  <tbody id='0Y1Up'></tbody>
              • 本文介绍了Selenium .set_script_timeout(n) 有什么作用,它与 driver.set_page_load_timeout(n) 有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 python selenium 的上下文中,我不太了解 driver.set_page_load_timeout(n) VS 的确切区别.driver.set_script_timeout(n).两者似乎可以互换使用来设置超时以通过 driver.get(URL) 加载 URL,但有时也可以一起使用.

                In context of python selenium, I don't quite understand the exact difference of driver.set_page_load_timeout(n) VS. driver.set_script_timeout(n). Both seem to be used interchangeable to set a timeout to load an URL via driver.get(URL), but sometimes also together.

                场景 1:

                driver.set_page_load_timeout(5)
                website = driver.get(URL)
                results = do_magic(driver, URL)
                

                场景 2:

                driver.set_script_timeout(5)
                website = driver.get(URL)
                results = do_magic(driver, URL)
                

                这两种情况有何不同?哪些情况会在一种情况下触发超时,而在另一种情况下不会触发?

                推荐答案

                根据 Selenium-Python API Docs set_page_load_timeout(n)set_script_timeout(n) 都是 timeout 方法,用于配置 webdriver 实例在程序执行期间遵守.

                As per the Selenium-Python API Docs set_page_load_timeout(n) and set_script_timeout(n) both are timeout methods which are used to configure the webdriver instance to abide by during the program execution.

                set_page_load_timeout(time_to_wait) 设置在抛出错误之前等待页面加载完成的时间量,定义为:

                set_page_load_timeout(time_to_wait) sets the amount of time to wait for a page load to complete before throwing an error and is defined as :

                    def set_page_load_timeout(self, time_to_wait):
                    """
                    Set the amount of time to wait for a page load to complete
                       before throwing an error.
                
                    :Args:
                     - time_to_wait: The amount of time to wait
                
                    :Usage:
                        driver.set_page_load_timeout(30)
                    """
                    try:
                        self.execute(Command.SET_TIMEOUTS, {
                        'pageLoad': int(float(time_to_wait) * 1000)})
                    except WebDriverException:
                        self.execute(Command.SET_TIMEOUTS, {
                        'ms': float(time_to_wait) * 1000,
                        'type': 'page load'})
                

                在这里您可以找到关于 set_page_load_timeout

                Here you can find a detailed discussion on set_page_load_timeout

                set_script_timeout(time_to_wait) 设置脚本在 execute_async_script (Javascript/AJAX Call) 在抛出错误之前调用,定义为:

                set_script_timeout(time_to_wait) sets the amount of time that the script should wait during an execute_async_script (Javascript / AJAX Call) call before throwing an error and is defined as :

                    def set_script_timeout(self, time_to_wait):
                    """
                    Set the amount of time that the script should wait during an
                       execute_async_script call before throwing an error.
                
                    :Args:
                     - time_to_wait: The amount of time to wait (in seconds)
                
                    :Usage:
                        driver.set_script_timeout(30)
                    """
                    if self.w3c:
                        self.execute(Command.SET_TIMEOUTS, {
                        'script': int(float(time_to_wait) * 1000)})
                    else:
                        self.execute(Command.SET_SCRIPT_TIMEOUT, {
                        'ms': float(time_to_wait) * 1000})
                

                这篇关于Selenium .set_script_timeout(n) 有什么作用,它与 driver.set_page_load_timeout(n) 有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:通过 webdriver 点击 javascript 弹出窗口 下一篇:selenium Python中的unittest是什么?

                相关文章

                <legend id='wDyLO'><style id='wDyLO'><dir id='wDyLO'><q id='wDyLO'></q></dir></style></legend>

              • <small id='wDyLO'></small><noframes id='wDyLO'>

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