Files
cmautobuy/client/src/util/loaded_pdd.py
T

31 lines
885 B
Python

import time
def wait_goods_page(device, timeout=30):
end_time = time.monotonic() + timeout
while time.monotonic() < end_time:
current = device.app_current()
if current.get("package") != "com.xunmeng.pinduoduo":
time.sleep(1)
continue
ready = any([
bool(device(textContains="发起拼单").exists),
bool(device(textContains="立即购买").exists),
bool(device(textContains="单独购买").exists),
bool(device(textContains="快要抢光").exists),
bool(device(textContains="免拼购买").exists),
])
loading = any([
bool(device(textContains="加载中").exists),
bool(device(textContains="正在加载").exists),
])
if ready and not loading:
return True
time.sleep(1)
return False