Best Python code snippet using Airtest
进入游戏测试.py
Source:进入游戏测试.py
...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)...
airdevice.py
Source:airdevice.py
...18 def device_id(self):19 """å½å设å¤ID"""20 return self.android.uuid21 @property22 def get_top_activity(self):23 """è·å顶级活å¨"""24 return self.android.get_top_activity()25 @property26 def get_default_ime(self):27 """è·åé»è®¤çè¾å
¥æ³"""28 return self.adb.shell("settings get secure default_input_method").strip()29 @property30 def get_ipv4(self):31 """[summary]32 è·åææºçIPå°å33 """34 return self.android.get_ip_address()35 def close_yosemite_ime(self, ime):36 """å
³éairtestè¾å
¥æ³"""37 self.adb.shell("ime disable %s" % YOSEMITE_IME_SERVICE)38 self.adb.shell("ime set %s" % ime)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!