Best Python code snippet using Airtest
multiscale_template_matching.py
Source: multiscale_template_matching.py
...139 if self.resolution[0]<self.im_search.shape[1] or self.resolution[1]<self.im_search.shape[0]:140 raise TemplateInputError("error: resolution is too small.")141 # 第äºæ¥ï¼è®¡ç®æ¨¡æ¿å¹é
çç»æç©éµres142 if not self.record_pos is None:143 area, self.resolution = self._get_area_scope(self.im_source, self.im_search, self.record_pos, self.resolution)144 self.im_source = aircv.crop_image(self.im_source, area)145 check_source_larger_than_search(self.im_source, self.im_search)146 r_min, r_max = self._get_ratio_scope(147 self.im_source, self.im_search, self.resolution)148 s_gray, i_gray = img_mat_rgb_2_gray(self.im_search), img_mat_rgb_2_gray(self.im_source)149 confidence, max_loc, w, h, _ = self.multi_scale_search(150 i_gray, s_gray, ratio_min=r_min, ratio_max=r_max, step=self.scale_step, threshold=self.threshold)151 if not self.record_pos is None:152 max_loc = (max_loc[0] + area[0], max_loc[1] + area[1])153 154 # æ±åè¯å«ä½ç½®: ç®æ ä¸å¿ + ç®æ åºå:155 middle_point, rectangle = self._get_target_rectangle(max_loc, w, h)156 best_match = generate_result(middle_point, rectangle, confidence)157 LOGGING.debug("[%s] threshold=%s, result=%s" %158 (self.METHOD_NAME, self.threshold, best_match))159 return best_match if confidence >= self.threshold else None160 else:161 return None162 def _get_ratio_scope(self, src, templ, resolution):163 """é¢æµç¼©æ¾æ¯çä¸ä¸é."""164 H, W = src.shape[0], src.shape[1]165 th, tw = templ.shape[0], templ.shape[1]166 w, h = resolution167 rmin = min(H/h, W/w) # æ°æ§æ¨¡æ¿æ¯ä¸é168 rmax = max(H/h, W/w) # æ°æ§æ¨¡æ¿æ¯ä¸é169 ratio = max(th/H, tw/W) # å°å¾å¤§å¾æ¯170 r_min = ratio*rmin171 r_max = ratio*rmax172 return max(r_min, self.scale_step), min(r_max, 0.99)173 def get_predict_point(self, record_pos, screen_resolution):174 """é¢æµç¼©æ¾åçç¹å»ä½ç½®ç¹."""175 delta_x, delta_y = record_pos176 _w, _h = screen_resolution177 target_x = delta_x * _w + _w * 0.5178 target_y = delta_y * _w + _h * 0.5179 return target_x, target_y180 def _get_area_scope(self, src, templ, record_pos, resolution):181 """é¢æµæç´¢åºå."""182 H, W = src.shape[0], src.shape[1]183 th, tw = templ.shape[0], templ.shape[1]184 w, h = resolution185 x, y = self.get_predict_point(record_pos, (W, H))186 predict_x_radius = max(int(tw * W / (w)), self.DEVIATION)187 predict_y_radius = max(int(th * H / (h)), self.DEVIATION)188 area = (189 max(x - predict_x_radius, 0),190 max(y - predict_y_radius, 0),191 min(x + predict_x_radius, W), 192 min(y + predict_y_radius, H),193 )194 return area, (w*(area[3]-area[1])/W, h*(area[2]-area[0])/H)
Check out the latest blogs from LambdaTest on this topic:
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.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
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!!