Skip to content

Commit c5211e5

Browse files
Print all matching ids in page
1 parent 8d19157 commit c5211e5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/appium_lib/android/helper.rb

+12-3
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,21 @@ def run node
358358
out += " name: #{e_desc}\n" unless e_desc.nil?
359359
end
360360

361-
id_match = @strings_xml.detect do |kv|
361+
# there may be many ids with the same value.
362+
# output all exact matches.
363+
id_matches = @strings_xml.select do |kv|
362364
value = kv.last
363365
value == e_desc || value == e_text
364366
end
365-
# [0] = key, [1] = value
366-
out += " id: #{id_match[0]}\n" if id_match
367+
368+
if id_matches && id_matches.length > 0
369+
match_str = ''
370+
# [0] = key, [1] = value
371+
id_matches.each do |match|
372+
match_str += ' ' * 6 + "#{match[0]}\n"
373+
end
374+
out += " id: #{match_str.strip}\n"
375+
end
367376
}
368377
out
369378
end

0 commit comments

Comments
 (0)