Best Python code snippet using Airtest
win.py
Source:win.py
...92 else:93 screen = screenshot(filename)94 if self.app:95 rect = self.get_rect()96 rect = self._fix_image_rect(rect)97 screen = aircv.crop_image(screen, [rect.left, rect.top, rect.right, rect.bottom])98 if not screen.any():99 if self.app:100 rect = self.get_rect()101 rect = self._fix_image_rect(rect)102 screen = aircv.crop_image(screenshot(filename), [rect.left, rect.top, rect.right, rect.bottom])103 if self._focus_rect != (0, 0, 0, 0):104 height, width = screen.shape[:2]105 rect = (self._focus_rect[0], self._focus_rect[1], width + self._focus_rect[2], height + self._focus_rect[3])106 screen = aircv.crop_image(screen, rect)107 if filename:108 aircv.imwrite(filename, screen, quality, max_size=max_size)109 return screen110 def _fix_image_rect(self, rect):111 """Fix rect in image."""112 # å°rect 转æ¢ä¸ºå·¦ä¸è§ä¸º(0,0), ä¸å¾çåæ 对é½113 rect.left = rect.left - self.monitor["left"]114 rect.right = rect.right - self.monitor["left"]115 rect.top = rect.top - self.monitor["top"]116 rect.bottom = rect.bottom - self.monitor["top"]117 return rect118 def keyevent(self, keyname, **kwargs):119 """120 Perform a key event121 References:122 https://pywinauto.readthedocs.io/en/latest/code/pywinauto.keyboard.html123 Args:124 keyname: key event...
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!!