Skip to content

Commit

Permalink
Merge pull request #90 from KeyLee123/master
Browse files Browse the repository at this point in the history
增加一个递归查找元素的方法
  • Loading branch information
mikigo authored Jul 24, 2024
2 parents 78787e1 + 9422fd8 commit d683a33
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/dogtail_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,25 @@ def find_element_by_attr_and_click(self, expr, index=0):

def find_element_by_attr_and_right_click(self, expr, index=0):
self.find_element_by_attr(expr, index).click(3)

def find_elements_by_recursive(self, ele_name):
"""
递归查找应用界面的元素(适用于查找多个同名称元素)
:param ele_name: 需要查找的元素名称
:return: 查找到的元素对象的列表
"""
eles = []
root_ele = self.obj

def recur_inter(node=None):
if not node:
node = root_ele
children = node.children
if children:
for i in children:
if i.combovalue == ele_name:
eles.append(i)
recur_inter(i)

recur_inter()
return eles

0 comments on commit d683a33

Please sign in to comment.