How to use _cal_scale method in ATX

Best Python code snippet using ATX

mixin.py

Source: mixin.py Github

copy

Full Screen

...128 if not safe:129 raise errors.ImageNotFoundError('Image not gone %s' % (pattern,))130 # def touch(self, x, y):131 # self.click(x, y)132 def _cal_scale(self, pattern=None):133 scale = 1.0134 resolution = (pattern and pattern.resolution) or self.resolution135 if resolution is not None:136 ow, oh = sorted(resolution)137 dw, dh = sorted(self.display)138 fw, fh = 1.0 * dw /​ ow, 1.0 * dh /​ oh139 # For horizontal screen, scale by Y (width)140 # For vertical screen, scale by X (height)141 scale = fw if self.rotation in (1, 3) else fh142 return scale143 @property144 def bounds(self):145 if self._bounds is None:146 return None147 return self._bounds * self._cal_scale()148 def match_all(self, pattern, threshold=None):149 pattern = self.pattern_open(pattern)150 search_img = pattern.image151 pattern_scale = self._cal_scale(pattern)152 if pattern_scale != 1.0:153 search_img = cv2.resize(search_img, (0, 0),154 fx=pattern_scale, fy=pattern_scale,155 interpolation=cv2.INTER_CUBIC)156 threshold = threshold or pattern.threshold or self.image_match_threshold157 screen = self.region_screenshot()158 screen = imutils.from_pillow(screen)159 points = ac.find_all_template(screen, search_img, threshold=threshold, maxcnt=10)160 return points161 def match(self, pattern, screen=None, rect=None, offset=None, threshold=None, method=None):162 pattern = self.pattern_open(pattern)163 search_img = pattern.image164 pattern_scale = self._cal_scale(pattern)165 if pattern_scale != 1.0:166 search_img = cv2.resize(search_img, (0, 0),167 fx=pattern_scale, fy=pattern_scale,168 interpolation=cv2.INTER_CUBIC)169 screen = screen or self.region_screenshot()170 threshold = threshold or pattern.threshold or self.image_match_threshold171 # handle offset if percent, ex (0.2, 0.8)172 dx, dy = offset or pattern.offset or (0, 0)173 dx = pattern.image.shape[1] * dx # opencv object width174 dy = pattern.image.shape[0] * dy # opencv object height175 dx, dy = int(dx * pattern_scale), int(dy * pattern_scale)176 # image match177 screen = imutils.from_pillow(screen) # convert to opencv image178 if rect and isinstance(rect, tuple) and len(rect) == 4:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Putting Together a Testing Team

As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

What is Selenium Grid & Advantages of Selenium Grid

Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.

QA’s and Unit Testing – Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

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