Disclaimer: This blog mainly provides ideas, and I personally think it is very practical.
1. Install AIRTEST, open it after the download is successful, connect the phone to enter the developer mode, as shown in the figure:
2. Refresh ADB, click connect to connect
3. Start writing script
3.1 We first define a function for signing in to the campus APP today
def jinrixiaoyuan():
3.2 Import the package name of today's campus
start_app("com.wisedu.cpdaily")
3.3 Call the touch function in the Airtest auxiliary window.
There are 4 parameters for the touch function. By default, we use the first
touch to take a screenshot of the button we want to click, and the code is automatically displayed
4. The code is as follows. The touch function needs to be written by your own needs
# -*- encoding=utf8 -*-
__author__ = "lenovo"
from airtest.core.api import *
auto_setup(__file__)
def jinrixiaoyuan():
home
start_app("com.wisedu.cpdaily")
touch(Template(r"tpl1603631461493.png", record_pos=(0.125, 1.014), resolution=(1080, 2280)))
touch(Template(r"tpl1603629590171.png", record_pos=(-0.059, -0.269), resolution=(1080, 2280)))
touch(Template(r"tpl1603629670575.png", record_pos=(-0.004, 0.802), resolution=(1080, 2280)))
touch(Template(r"tpl1603630968155.png", record_pos=(0.01, -0.2), resolution=(1080, 2280)))
jinrixiaoyuan()
5. Click the triangle button (F5) above to run the screenshot as follows
Attachment: Automatically sign in common APP package name and interface name
# 新浪微博
com.sina.weibo/.SplashActivity
# Bilibili
tv.danmaku.bili/.ui.splash.SplashActivity
# 联通助手
com.sinovatech.unicom.ui/com.sinovatech.unicom.basic.ui.activity.WelcomeClient
# 有道
com.youdao.note/.activity2.SplashActivity
# 京东
com.jingdong.app.mall/.main.MainActivity
# 淘宝
com.taobao.taobao/com.taobao.tao.welcome.Welcome
# 今日头条
com.ss.android.article.lite/.activity.SplashActivity
# 喜马拉雅
com.ximalaya.ting.android/.host.activity.WelComeActivity
# 抖音
com.ss.android.ugc.aweme.lite/com.ss.android.ugc.aweme.splash.SplashActivity
# 快手
com.kuaishou.nebula/com.yxcorp.gifshow.HomeActivity
# 携程
ctrip.android.view/ctrip.business.splash.CtripSplashActivity
# 闲鱼
com.taobao.idlefish/com.taobao.fleamarket.home.activity.InitActivity
# 拼多多APP
com.xunmeng.pinduoduo/.ui.activity.MainFrameActivity
# 美团
com.sankuai.meituan/com.meituan.android.pt.homepage.activity.Welcome
# 饿了么
me.ele/.application.ui.Launcher.LauncherActivity
# 大众点评
com.dianping.v1/com.dianping.main.guide.LaunchActivity
# 口碑
com.taobao.mobile.dipei/com.eg.android.AlipayGphone.AlipayLogin
# 华为商城
com.vmall.client/.splash.fragment.SplashActivity
# QQ浏览器
com.tencent.mtt/.SplashActivity
# 百度APP
com.baidu.searchbox/.SplashActivity
# 支付宝APP
com.eg.android.AlipayGphone/.AlipayLogin
If the operation is not successful, or if you encounter problems, please leave a message in the comment area to correct me