Best Python code snippet using ATX
__init__.py
Source:__init__.py
...61 cv_last_img = imutils.from_pillow(self.last_screenshot)62 cv_last_img = imutils.mark_point(cv_last_img, x, y)63 screen = imutils.to_pillow(cv_last_img)64 screen_before = self._save_screenshot()65 self._add_to_gif(screen)66 # screen_before = self._save_screenshot(self.last_screenshot)67 # FIXME: maybe need sleep for a while68 screen_after = self._save_screenshot(append_gif=True)69 self.add_step('click',70 screen_before=screen_before,71 screen_after=screen_after,72 position={'x': x, 'y': y})73 def add_step(self, action, **kwargs):74 kwargs['success'] = kwargs.pop('success', True)75 kwargs['time'] = round(kwargs.pop('time', time.time()-self.start_time), 1)76 kwargs['action'] = action77 self.steps.append(kwargs)78 def _save_screenshot(self, screen=None, name=None, append_gif=False):79 if screen is None:80 screen = self.d.screenshot()81 if name is None:82 name = 'images/before_%d.png' % time.time()83 relpath = os.path.join(self.save_dir, name)84 screen.save(relpath)85 if append_gif:86 self._add_to_gif(screen)87 return name88 def _add_to_gif(self, image):89 half = 0.590 out = image.resize([int(half*s) for s in image.size])91 cvimg = imutils.from_pillow(out)92 self.__gif.append_data(cvimg[:, :, ::-1])93 def patch_uiautomator(self):94 """ record steps of uiautomator """95 import uiautomator96 uiautomator.add_listener('atx-report', self._uia_listener)97 def patch_wda(self):98 """ record steps of webdriveragent """99 import wda100 def _click(that):101 rawx, rawy = that.bounds.center102 x, y = self.d.scale*rawx, self.d.scale*rawy...
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!!