zoukankan      html  css  js  c++  java
  • Helium文档8-WebUI自动化-wait_until等待元素出现

    前言

    wait_until等待某个条件为真才继续往下执行。默认的超时时间为10s,每0.5查询一次,这俩参数选填。可以设置超时时间和轮询间隔。

    可以作为添加后校验元素是否存在的场景

    入参介绍

    def wait_until(condition_fn, timeout_secs=10, interval_secs=0.5):
    """
    :param condition_fn: A function taking no arguments that represents the
    condition to be waited for.
    :param timeout_secs: The timeout, in seconds, after which the condition is
    deemed to have failed.
    :param interval_secs: The interval, in seconds, at which the condition
    function is polled to determine whether the wait has succeeded.

    Waits until the given condition function evaluates to true. This is most
    commonly used to wait for an element to exist::

    wait_until(Text("Finished!").exists)

    More elaborate conditions are also possible using Python lambda
    expressions. For instance, to wait until a text no longer exists::

    wait_until(lambda: not Text("Uploading...").exists())

    ``wait_until`` raises
    :py:class:`selenium.common.exceptions.TimeoutException` if the condition is
    not satisfied within the given number of seconds. The parameter
    ``interval_secs`` specifies the number of seconds Helium waits between
    evaluating the condition function.
    """
    _get_api_impl().wait_until_impl(condition_fn, timeout_secs, interval_secs)

    举例说明

    wait_until(Text("Finished!").exists)  # 等待直到给定的条件函数评估为true。 这是最通常用于等待元素存在,失败后直接报错
    wait_until(lambda: not Text("Uploading...").exists())  # 例如,等待直到文本不再存在

    欢迎关注

    
    
  • 相关阅读:
    BZOJ2821 作诗(Poetize) 【分块】
    BZOJ2724 蒲公英 【分块】
    Codeforces 17E Palisection 【Manacher】
    BZOJ2565 最长双回文串 【Manacher】
    Codeforces 25E Test 【Hash】
    CODEVS3013 单词背诵 【Hash】【MAP】
    HDU2825 Wireless Password 【AC自动机】【状压DP】
    HDU2896 病毒侵袭 【AC自动机】
    HDU3065 病毒侵袭持续中【AC自动机】
    HDU2222 Keywords Search 【AC自动机】
  • 原文地址:https://www.cnblogs.com/weitung/p/13568248.html
Copyright © 2011-2022 走看看