栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Selenium .set_script_timeout(n)有什么作用,它与driver.set_page_load_timeout(n)有何不同?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Selenium .set_script_timeout(n)有什么作用,它与driver.set_page_load_timeout(n)有何不同?

根据 Selenium-Python API Docs

set_page_load_timeout(n)
set_script_timeout(n)
两者都是 超时 方法,用于将 webdriver
实例配置为在程序执行期间遵守。

set_page_load_timeout(time_to_wait)

set_page_load_timeout(time_to_wait)

设置在引发错误之前等待页面加载完成的时间,其定义为:

    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

set_script_timeout(time_to_wait)

set_script_timeout(time_to_wait)

设置脚本在抛出错误之前
execute_async_script

Javascript / AJAX调用 )应等待的时间,其定义为:

    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})


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/436094.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号