A. poco wait
wait without error
wait for elements for 10 seconds. If it's not appeared, there won't be any error raised.
poco('xxx').wait(timeout=10)
and you can follow some operations after .wait(), like click or long_click
poco('xxx').wait(timeout=10).click()
poco('xxx').wait(timeout=10).long_click()
wait with error
wait for elements for 10 seconds. If the element isn't appeared, PocoTargetTimeout error will be raised.
poco('xxx').wait_for_appearance(20)
poco('xxx').wait_for_disappearance(20) # wait for disappearance of the element
common use:
from poco.exceptions import PocoTargetTimeout
try:
poco('xxx').wait_for_appearance(20)
except PocoTargetTimeout:
# logging...
# raise ...
wait for elements(no time setting)
wait_for_all() wil wait until all the elements appeared. wait_for_any() will wait until any one of the elements appeared.
yellow = poco("yellow")
blue = poco("blue")
black = poco("black")
poco.wait_for_all([yellow,blue,black])
# poco.wait_for_any([yellow,blue,black])
poco('xxx').click() # if the elements above not appeared, this click will not be operated
check if exist without wait
poco('xxx').exists() will return True or False to tell you the current state of the elements(no error will be raised).
if poco('xxx').exists():
# some operations if find the element
else:
# some operations if not find the element
B. Airtest wait
from airtest.core.api import *
# exist
exists(some_element) # return True or False
# wait - if not appear, TargetNotFoundError will be raised
wait(some_element, timeout=5)
# wait - the default value of timeout is set by ST.FIND_TIMEOUT
wait(some_element)