Best Python code snippet using Airtest
resolution.py
Source:resolution.py
...22 res_x, res_y = src_resolution23 else:24 res_y, res_x = im_source.shape[:2]25 prePos_x, prePos_y = clk_x * res_x + 0.5 * res_x, clk_y * res_x + 0.5 * res_y26 def safe_xy(val, min_val, max_val):27 return min(max(min_val, val), max_val)28 # å以é¢æµç¹ä¸ºä¸å¿ï¼è¿è¡èå´æå:29 start_x = int(safe_xy(prePos_x - radius_x, 0, res_x - 1))30 end_x = int(safe_xy(prePos_x + radius_x, 0, res_x - 1))31 start_y = int(safe_xy(prePos_y - radius_y, 0, res_y - 1))32 end_y = int(safe_xy(prePos_y + radius_y, 0, res_y - 1))33 # å¦æåç°é¢æµåºåå®å
¨å¨å¾åå¤ï¼é¢æµåºåå°åªå©ä¸ä¸æ¡åç´ ï¼é¢æµå¤±è´¥ï¼ç´æ¥raise:34 if start_x == end_x or start_y == end_y:35 img_src, left_top_pos = im_source, (0, 0)36 log_info = "Predict area's width or height has just one pixel, abandon prediction."37 else:38 # é¢æµåºåæ£å¸¸ï¼åæªåé¢æµåºåï¼å¹¶å°é¢æµåºåå¨æºå¾åä¸çä½ç½®ä¸å¹¶è¿å:39 img_src = im_source[start_y:end_y, start_x:end_x]40 left_top_pos = (start_x, start_y)41 # è¾åºè°è¯ä¿¡æ¯.42 log_info = "predict rect: X (%(start_x)s:%(end_x)s) Y (%(start_y)s:%(end_y)s)" % {"start_x": start_x, "end_x":end_x, "start_y": start_y, "end_y": end_y}...
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!!