Like a circle of friends automatically based on the point airtest

This script can be executed by AirtestIDE and python, it recommended the use of AirtestIDE the execution environment, more stable
AirtestIDE official documents

Using python script to perform the
installation library airtest, pocoui

pip install airtest
pip install pocoui

code show as below

# -*- encoding=utf8 -*-
__author__ = "admin"
from airtest.core.api import *
from poco.drivers.android.uiautomation import AndroidUiautomationPoco

poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)
connect_device("Android://127.0.0.1:5037/f350e2f7")
print("start...")
PKG = "com.tencent.mm"  # 微信包名
stop_app(PKG)  # 关闭此app
wake()  # 唤醒并解锁设备
home()  # 返回HOME界面
start_app(PKG)  # 启动此app

poco(text='发现').wait(2).click()
pyq = poco(text='朋友圈')
pyq.click()

while True:
    try:
        # 评论按钮
        comments = poco("com.tencent.mm:id/eho")
        for comment in comments:
            childX, childY = comment.get_position()
            print(childX)
            print(childY)
            if (childY >= 0.1 and childY < 1.0):
                comment.click()
                zan = poco(text='赞')
                if zan.exists():
                    zan.click()
    except Exception as e:
        print('error'+str(e))
        keyevent("BACK")  # 有可能进入其它页面,调用系统级返回按钮
        if pyq.exists(): # 如果返回到发现页,重新进入朋友圈
            pyq.click()
    swipe((500, 1700), (500, 900))  # 向上滑动

From https://blog.csdn.net/qq_38534107/article/details/93232179

Guess you like

Origin www.cnblogs.com/hankleo/p/11264850.html