Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit ce2cba4

Browse files
feat: Adds parameters for descendants and ancestor
1 parent 9eeac97 commit ce2cba4

File tree

2 files changed

+54
-12
lines changed

2 files changed

+54
-12
lines changed

‎AppiumFlutterLibrary/finder/elementfinder.py‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,46 @@ def _find_by_type(self, application, type, **kwargs):
8080

8181
return element
8282

83-
def _get_descendant(self, application, of, matching) -> FlutterElement:
83+
def _get_descendant(
84+
self,
85+
application,
86+
of: str,
87+
matching: str,
88+
match_root: bool = False,
89+
first_match_only: bool = False,
90+
) -> FlutterElement:
8491
finder_descendant = self._element_finder.by_descendant(
85-
self.find(application, of, serialized=True),
86-
self.find(application, matching, serialized=True)
92+
self.find(
93+
application, of, serialized=True,
94+
match_root=match_root, first_match_only=first_match_only
95+
),
96+
self.find(
97+
application, matching, serialized=True,
98+
match_root=match_root, first_match_only=first_match_only
99+
)
87100
)
88101

89102
element = FlutterElement(application, finder_descendant)
90103

91104
return element
92105

93-
def _get_ancestor(self, application, of, matching) -> FlutterElement:
106+
def _get_ancestor(
107+
self,
108+
application,
109+
of: str,
110+
matching: str,
111+
match_root: bool = False,
112+
first_match_only: bool = False,
113+
) -> FlutterElement:
94114
finder_descendant = self._element_finder.by_ancestor(
95-
self.find(application, of, serialized=True),
96-
self.find(application, matching, serialized=True)
115+
self.find(
116+
application, of, serialized=True,
117+
match_root=match_root, first_match_only=first_match_only
118+
),
119+
self.find(
120+
application, matching, serialized=True,
121+
match_root=match_root, first_match_only=first_match_only
122+
)
97123
)
98124

99125
element = FlutterElement(application, finder_descendant)

‎AppiumFlutterLibrary/keywords/_element.py‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,41 @@ def get_element_text(self, locator: str | FlutterElement):
113113
self._info("Element '%s' text is '%s' " % (locator, text))
114114
return text
115115

116-
def get_element_descendant(self, of: str, matching: str) -> FlutterElement:
116+
def get_element_descendant(
117+
self,
118+
of: str,
119+
matching: str,
120+
match_root: bool = False,
121+
first_match_only: bool = False,
122+
) -> FlutterElement:
117123
"""Returns the element's descendant
118124
119125
Params:
120126
of: locator for the parent element
121127
matching: locator for the child element
122128
"""
123129
application = self._current_application()
124-
return self._element_finder._get_descendant(application, of, matching)
125-
126-
def get_element_ancestor(self, of: str, matching: str) -> FlutterElement:
130+
return self._element_finder._get_descendant(
131+
application, of, matching, match_root, first_match_only
132+
)
133+
134+
def get_element_ancestor(
135+
self,
136+
of: str,
137+
matching: str,
138+
match_root: bool = False,
139+
first_match_only: bool = False,
140+
) -> FlutterElement:
127141
"""Returns the element's ancestor
128142
129143
Params:
130144
of: locator for the parent element
131145
matching: locator for the child element
132146
"""
133-
applicaiton = self.current_application()
134-
return self._element_finder._get_ancestor(applicaiton, of, matching)
147+
application = self.current_application()
148+
return self._element_finder._get_ancestor(
149+
application, of, matching, match_root, first_match_only
150+
)
135151

136152
def _is_visible(self, element):
137153
application = self._current_application()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /