杰讯山西网站建设,网站开发项目建设规范,多网合一网站平台建设,ipv6域名解析 做网站app爬虫中的Airtest元素存在或等待
一. poco等待
等待无错误 等待元素10秒。如果它没有出现#xff0c;则不会引发任何错误。
poco(xxx).wait(timeout10)您还可以在.wait()之后执行一些操作#xff0c;如click或long_click
poco(xxx).wait(timeout10).click()
poco(xxx).…app爬虫中的Airtest元素存在或等待
一. poco等待
等待无错误 等待元素10秒。如果它没有出现则不会引发任何错误。
poco(xxx).wait(timeout10)您还可以在.wait()之后执行一些操作如click或long_click
poco(xxx).wait(timeout10).click()
poco(xxx).wait(timeout10).long_click()等待错误 等待元素10秒。如果元素未出现将引发PocoTargetTimeout错误。
poco(xxx).wait_for_appearance(20)
poco(xxx).wait_for_disappearance(20) # wait for disappearance of the element常见的使用:
from poco.exceptions import PocoTargetTimeouttry:poco(xxx).wait_for_appearance(20)
except PocoTargetTimeout:# logging...# raise ...等待元素(没有时间设置) Wait_for_all()将等待所有元素出现。Wait_for_any()将等待直到任何一个元素出现。
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检查是否存在不要等待 poco(‘xxx’).exists() 将返回True或False来告诉你元素的当前状态(不会引发错误)。
if poco(xxx).exists():# some operations if find the element
else:# some operations if not find the element二. 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, timeout5)
# wait - the default value of timeout is set by ST.FIND_TIMEOUT
wait(some_element)