Best Python code snippet using Airtest
test_minicap.py
Source:test_minicap.py
...29 frame = self.minicap.get_frame()30 frame = string_2_img(frame)31 self.assertIsInstance(frame, ndarray)32 def test_get_frames(self):33 frame = self.minicap.get_frame_from_stream()34 frame = string_2_img(frame)35 self.assertIsInstance(frame, ndarray)36 def test_rotation(self):37 self.dev.keyevent("HOME")38 time.sleep(1)39 frame_vertical = self.minicap.get_frame_from_stream()40 frame_vertical = string_2_img(frame_vertical)41 self.dev.start_app(PKG)42 time.sleep(1)43 frame_horizontal = self.minicap.get_frame_from_stream()44 frame_horizontal = string_2_img(frame_horizontal)45 self.assertEqual(frame_vertical.shape[0], frame_horizontal.shape[1])46 self.assertEqual(frame_vertical.shape[1], frame_horizontal.shape[0])47 self.assertEqual(self._count_server_proc(), 1)48class TestMinicapSetup(TestMinicapBase):49 def test_0_install(self):50 self.minicap.uninstall()51 self.minicap.install()52 def test_teardown(self):53 self.minicap.get_frame_from_stream()54 self.minicap.teardown_stream()55 self.assertEqual(self._count_server_proc(), 0)56if __name__ == '__main__':...
base_cap.py
Source:base_cap.py
...7 ææå±å¹æªå¾æ¹æ³çåºç±»8 """9 def __init__(self, adb, *args, **kwargs):10 self.adb = adb11 def get_frame_from_stream(self):12 """13 Get a frame of the current screen from the mobile screen stream14 ä»ææºç»é¢æµä¸ï¼è·åä¸å¼ å½åå±å¹æªå¾15 Returns: frame_data16 """17 raise NotImplementedError18 def get_frame(self):19 # è·å¾åå¼ å±å¹æªå¾20 return self.get_frame_from_stream()21 def teardown_stream(self):22 pass23 def snapshot(self, ensure_orientation=True, *args, **kwargs):24 """25 Take a screenshot and convert it into a cv2 image object26 è·åä¸å¼ å±å¹æªå¾ï¼å¹¶è½¬åæcv2çå¾å对象27 Returns: numpy.ndarray28 """29 screen = self.get_frame_from_stream()30 try:31 screen = aircv.utils.string_2_img(screen)32 except Exception:33 # may be black/locked screen or other reason, print exc for debugging34 traceback.print_exc()35 return None...
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!!