From 019a073d63a927af130c45b89805f5adf99add5b Mon Sep 17 00:00:00 2001 From: ut001652 Date: Wed, 11 Sep 2024 17:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=9C=E7=A8=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dogtail_utils.py | 12 ++++++++++-- src/remotectl/remote.py | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dogtail_utils.py b/src/dogtail_utils.py index 4eb28df8..22102464 100644 --- a/src/dogtail_utils.py +++ b/src/dogtail_utils.py @@ -72,6 +72,14 @@ def app_element(self, *args, **kwargs) -> Node: except SearchError: raise ElementNotFound(*args, **kwargs) from SearchError + def get_element_children_text(self, element): + element = self.app_element(element) + all_children = element.children + text = [] + for i in range(len(all_children)): + text.append(all_children[i].name) + return text + def left_upper_corner_position(self, element) -> tuple: """ 获取元素左上角的坐标 @@ -170,7 +178,7 @@ def __trace(self, element, result, expr): else: return False try: - next_node = name[node.end() - 1 :] + next_node = name[node.end() - 1:] if next_node != "/": for i in element: self.__trace(i, result, next_node) @@ -238,4 +246,4 @@ def recur_inter(node=None): recur_inter(i) recur_inter() - return eles \ No newline at end of file + return eles diff --git a/src/remotectl/remote.py b/src/remotectl/remote.py index 4499cc84..7dac969a 100644 --- a/src/remotectl/remote.py +++ b/src/remotectl/remote.py @@ -67,7 +67,13 @@ def rdog(self) -> DogtailUtils: ) def click_element_by_attr(self, element, button=1): - self.rdog.element_click(element, button=button) + self.rdog.element_click(element, button) + + def get_element_children_txt(self, element): + return self.rdog.get_element_children_text(element) + + def get_element_center(self, element): + return self.rdog.element_center(element) @property def rctl(self) -> Src: