File tree 3 files changed +36
-0
lines changed
3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,16 @@ def name name
91
91
mobile :find , [ [ [ 7 , name ] ] ]
92
92
end
93
93
94
+ # Return the first element exactly matching name.
95
+ # on Android name is content description
96
+ # on iOS name is the accessibility label or the text.
97
+ # @param name [String] the name to search for
98
+ # @return [Element] the first matching element
99
+ def name_exact name
100
+ # exact description
101
+ mobile :find , [ [ [ 5 , name ] ] ]
102
+ end
103
+
94
104
# Return all elements matching name.
95
105
# on Android name is content description
96
106
# on iOS name is the accessibility label or the text.
@@ -114,4 +124,17 @@ def scroll_to text
114
124
115
125
mobile :find , args
116
126
end
127
+
128
+ # Scroll to an element with the exact target text or description.
129
+ # @param text [String] the text to search for in the text value and content description
130
+ # @return [Element] the element scrolled to
131
+ def scroll_to_exact text
132
+ args = 'scroll' ,
133
+ # text(text)
134
+ [ [ 1 , text ] ] ,
135
+ # description(text)
136
+ [ [ 5 , text ] ]
137
+
138
+ mobile :find , args
139
+ end
117
140
end # module Appium::Android
Original file line number Diff line number Diff line change @@ -227,6 +227,14 @@ def tag tag_name
227
227
find_element :tag_name , tag_name
228
228
end
229
229
230
+ # Returns all elements matching tag_name
231
+ #
232
+ # @param tag_name [String] the tag_name to search for
233
+ # @return [Element]
234
+ def tags tag_name
235
+ find_elements :tag_name , tag_name
236
+ end
237
+
230
238
# Converts pixel values to window relative values
231
239
#
232
240
# ```ruby
Original file line number Diff line number Diff line change @@ -118,6 +118,11 @@ def name name
118
118
mobile :findElementNameContains , name : name
119
119
end
120
120
121
+ def name_exact name
122
+ js = all_ele_js "name == '#{ name } '"
123
+ execute_script js
124
+ end
125
+
121
126
# Return all elements matching name.
122
127
# on Android name is content description
123
128
# on iOS name is the accessibility label or the text.
You can’t perform that action at this time.
0 commit comments