How to use _neo_wda_screenshot method in Airtest

Best Python code snippet using Airtest

ios.py

Source:ios.py Github

copy

Full Screen

...115 w, h = h, w116 return w, h117 def home(self):118 return self.driver.home()119 def _neo_wda_screenshot(self):120 """121 this is almost same as wda implementation, but without png header check,122 as response data is now jpg format in mid quality123 """124 value = self.driver.http.get('screenshot').value125 raw_value = base64.b64decode(value)126 return raw_value127 def snapshot(self, filename=None, strType=False, ensure_orientation=True):128 """129 take snapshot130 filename: save screenshot to filename131 """132 data = None133 if self.cap_method == CAP_METHOD.MINICAP:134 raise NotImplementedError135 elif self.cap_method == CAP_METHOD.MINICAP_STREAM:136 raise NotImplementedError137 elif self.cap_method == CAP_METHOD.WDACAP:138 data = self._neo_wda_screenshot() # wda 截图不用考虑朝向139 # 实时刷新手机画面,直接返回base64格式,旋转问题交给IDE处理140 if strType:141 if filename:142 with open(filename, 'wb') as f:143 f.write(data)144 return data145 # output cv2 object146 try:147 screen = aircv.utils.string_2_img(data)148 except:149 # may be black/locked screen or other reason, print exc for debugging150 traceback.print_exc()151 return None152 h, w = screen.shape[:2]...

Full Screen

Full Screen

iosfuncs.py

Source:iosfuncs.py Github

copy

Full Screen

...124 raise NotImplementedError125 elif self.cap_method == CAP_METHOD.MINICAP_STREAM:126 raise NotImplementedError127 elif self.cap_method == CAP_METHOD.WDACAP:128 data = self._neo_wda_screenshot() # wda 截图不用考虑朝向129 if strType:130 if filename:131 with open(filename, 'wb') as f:132 f.write(data)133 return data134 # output cv2 object135 try:136 screen = string_2_img(data)137 except:138 # may be black/locked screen or other reason, print exc for debugging139 import traceback140 traceback.print_exc()141 return None142 now_orientation = self.orientation143 # ensure the orientation is right144 if ensure_orientation and now_orientation in [LANDSCAPE, LANDSCAPE_RIGHT]:145 # minicap screenshots are different for various sdk_version146 if self.cap_method in (CAP_METHOD.MINICAP, CAP_METHOD.MINICAP_STREAM):147 h, w = screen.shape[:2] # cvshape是高度在前面!!!!148 if w < h: # 当前是横屏,但是图片是竖的,则旋转,针对sdk<=16的机器149 screen = rotate(screen, self.display_info["orientation"] * 90, clockwise=False)150 # wda 截图是要根据orientation旋转151 elif self.cap_method == CAP_METHOD.WDACAP:152 # seems need to rotate in opencv opencv-contrib-python==3.2.0.7153 screen = rotate(screen, 90, clockwise=(now_orientation == LANDSCAPE_RIGHT))154 # readed screen size155 h, w = screen.shape[:2]156 # save last res for portrait157 if now_orientation in [LANDSCAPE, LANDSCAPE_RIGHT]:158 self._size['height'] = w159 self._size['width'] = h160 else:161 self._size['height'] = h162 self._size['width'] = w163 winw, winh = self.window_size()164 self._touch_factor = float(winh) / float(h)165 # save as file if needed166 if filename:167 imwrite(filename, screen)168 return screen169 def _neo_wda_screenshot(self):170 """171 this is almost same as wda implementation, but without png header check,172 as response data is now jpg format in mid quality173 """174 value = self.driver.http.get('screenshot').value175 raw_value = base64.b64decode(value)176 return raw_value177 def _touch_point_by_orientation(self, tuple_xy):178 """179 Convert image coordinates to physical display coordinates, the arbitrary point (origin) is upper left corner180 of the device physical display181 Args:182 tuple_xy: image coordinates (x, y)183 Returns:...

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