[python] multiple uses of time waiting

The first way to wait: forced to wait
sometimes does not need to wait so long

    time.sleep(5)

The second waiting method: intelligent waiting

# 等待,wait超时时间默认是20s,如果20s内未等到,也不会再等。
# 可以修改默认等待时长,可以设短,或者设长,根据自己的需求来修改。
# 修改默认等待时长的方式有以下2种方式:
#方式一:    d.wait_timeout = 15
#方式二:    d.implicitly_wait(15)
	d.wait_timeout = 15
    d.app_start(pkg_name, wait=True)

# 前面设置的wait_timeout = 15 是全局变量,如果某个单独的操作需要等待更长# 的时间,可以单独设置timeout的。
    d(resourceId="android:id/tabhost").click(timeout=50)
    d(resourceId="android:id/tabhost").set_text(timeout=50)


  • Wait for the page to load: d.wait_activity()
  • Wait for the element to appear: d().wait()
  • Wait for the element to disappear: d().wait_gone()
  • Wait for the existence of an element: d().exist()
  • Wait for the click, after setting the implicit wait,
  • click,long_click,drag_to,get_text,set_text,clear_text.

Guess you like

Origin blog.csdn.net/Moonlight_16/article/details/125308953