How to use get_top_activity method in Airtest

Best Python code snippet using Airtest


Source:进入游戏测试.py Github


Full Screen

...12auto_setup(__file__)13# info = TMApkManager.getapkinfo(TestHelper.getPackagePath())14deviceinfo = TestHelper.getDeviceInfo()15info = TMApkManager.getapkinfo(TestHelper.getPackagePath())16package_name, activity_name, pid = G.DEVICE.adb.get_top_activity()17# 引擎闪退确认18logplus(f'package_name={package_name} info.packagename={info.packagename}')19assert_stopalltest(package_name == info.packagename)20sleep(3)21keyevent('BACK')22# TestHelper.back(deviceinfo.serialno)23sleep(3)24keyevent('BACK')25# TestHelper.back(deviceinfo.serialno)26sleep(3)27# 卡死测试28assert_not_exists(Template(r"tpl1618364020907.png", rgb=True, threshold=0.85, record_pos=(-0.001, -0.006), resolution=(1920, 1080)),'断言进入游戏')29package_name, activity_name, pid = G.DEVICE.adb.get_top_activity()30# 游戏流程闪退确认31assert_stopalltest(package_name == info.packagename)...

Full Screen

Full Screen Github


Full Screen

...18 def device_id(self):19 """当前设备ID"""20 return @property22 def get_top_activity(self):23 """获取顶级活动"""24 return @property26 def get_default_ime(self):27 """获取默认的输入法"""28 return"settings get secure default_input_method").strip()29 @property30 def get_ipv4(self):31 """[summary]32 获取手机的IP地址33 """34 return def close_yosemite_ime(self, ime):36 """关闭airtest输入法"""37"ime disable %s" % YOSEMITE_IME_SERVICE)38"ime set %s" % ime)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?