How to use _fix_image_rect method in Airtest

Best Python code snippet using Airtest

win.py

Source:win.py Github

copy

Full Screen

...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...

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:

YouTube

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?

Helpful

NotHelpful