Best Python code snippet using Airtest
ui.py
Source:ui.py
...53 action = 'ui.swipe'54 pprint(log)55 @logwrap56 def command_layer(action, params):57 traverse_layer(action, params)58 log_in_func({"name": action, 'ret': None})59 @logwrap60 def traverse_layer(action, params):61 snapshot()62 if uiobj and 'visibleBounds' in uiobj:63 b = uiobj['visibleBounds']['bottom']64 l = uiobj['visibleBounds']['left']65 r = uiobj['visibleBounds']['right']66 t = uiobj['visibleBounds']['top']67 68 if params and params[-1] == "topleft": # ç¹å»è¯å«åºåçå·¦ä¸è§69 x, y = l, t70 elif params and params[-1] == "bottomright": # ç¹å»è¯å«åºåçå³ä¸è§71 x, y = r, b72 else: # ç¹å»ä¸é´ä½ç½®73 x, y = (l + r) / 2, (b + t) / 274 log_in_func({...
mirror_tree+layer_traverse.py
Source:mirror_tree+layer_traverse.py
...69 for i in sequence:70 sequence_.append(i.lchild)71 sequence_.append(i.rchild)72 return self.judge_m(sequence=sequence_)73 def traverse_layer(self, sequence: list = []):74 if not sequence:75 return self.traverse_layer(sequence=[self.root_node])76 else:77 layer_list: list = []78 for i in sequence:79 if i.value:80 layer_list.append(i.value)81 self.layer_.append(layer_list)82 if sequence[0].lchild:83 next_sq = []84 for i in sequence:85 next_sq.append(i.lchild)86 next_sq.append(i.rchild)87 self.traverse_layer(sequence=next_sq)88a = Tree(value_list=[1, 2, 2, 3, 4, 4, 4])89a.generate_tree()90# a.pre_traverse_tree(current_node=a.root_node)91# print(a.judge_mirror_tree(current_node=a.root_node))92# print(a.judge_m())93a.traverse_layer()...
Q572_Subtree-of-Another-Tree_v2.py
Source:Q572_Subtree-of-Another-Tree_v2.py
...18 if not root:19 return False20 return compare_tree(root, subRoot) or compare_tree(root.left, subRoot) or compare_tree(root.right, subRoot)21 22 def traverse_layer(root, target, cnt=0):23 if not root:24 return False25 if cnt <= target:26 return any([compare_tree(root, subRoot),27 traverse_layer(root.left, target, cnt=cnt+1),28 traverse_layer(root.right, target, cnt=cnt+1)])29 return any([traverse_layer(root.left, target, cnt=cnt+1),30 traverse_layer(root.right, target, cnt=cnt+1)])31 32 33 def height_of_tree(root):34 if not root:35 return 036 return 1+max(height_of_tree(root.left), height_of_tree(root.right))37 height_of_root = height_of_tree(root)38 height_of_subroot = height_of_tree(subRoot)39 target = height_of_root - height_of_subroot40 if target < 0:41 return False42 ...
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!!