Skip to content

Commit a5b85de

Browse files
Add scroll_to_exact for Android & more
Add tags for iOS/Android Add name_exact for iOS/Android
1 parent cc7e778 commit a5b85de

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

lib/appium_lib/android/element/generic.rb

+23
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ def name name
9191
mobile :find, [ [ [7, name] ] ]
9292
end
9393

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+
94104
# Return all elements matching name.
95105
# on Android name is content description
96106
# on iOS name is the accessibility label or the text.
@@ -114,4 +124,17 @@ def scroll_to text
114124

115125
mobile :find, args
116126
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
117140
end # module Appium::Android

lib/appium_lib/common/helper.rb

+8
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ def tag tag_name
227227
find_element :tag_name, tag_name
228228
end
229229

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+
230238
# Converts pixel values to window relative values
231239
#
232240
# ```ruby

lib/appium_lib/ios/element/generic.rb

+5
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ def name name
118118
mobile :findElementNameContains, name: name
119119
end
120120

121+
def name_exact name
122+
js = all_ele_js "name == '#{name}'"
123+
execute_script js
124+
end
125+
121126
# Return all elements matching name.
122127
# on Android name is content description
123128
# on iOS name is the accessibility label or the text.

0 commit comments

Comments
 (0)