Skip to content

Commit d887050

Browse files
xml_keys, xml_values, resolve_id work on iOS
1 parent e148f2a commit d887050

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

lib/appium_lib/android/helper.rb

-28
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,6 @@ def page_class
307307
nil
308308
end
309309

310-
def lazy_load_strings
311-
@strings_xml ||= mobile(:getStrings)
312-
end
313-
314310
# Android only.
315311
# Returns a string containing interesting elements.
316312
# If an element has no content desc or text, then it's not returned by this method.
@@ -416,30 +412,6 @@ def fast_duration
416412
0.20
417413
end
418414

419-
# Search strings.xml's values for target.
420-
# @param target [String] the target to search for in strings.xml values
421-
# @return [Array]
422-
def xml_keys target
423-
lazy_load_strings
424-
@strings_xml.select { |key, value| key.downcase.include? target.downcase }
425-
end
426-
427-
# Search strings.xml's keys for target.
428-
# @param target [String] the target to search for in strings.xml keys
429-
# @return [Array]
430-
def xml_values target
431-
lazy_load_strings
432-
@strings_xml.select { |key, value| value.downcase.include? target.downcase }
433-
end
434-
435-
# Resolve id in strings.xml and return the value.
436-
# @param id [String] the id to resolve
437-
# @return [String]
438-
def resolve_id id
439-
lazy_load_strings
440-
@strings_xml[id]
441-
end
442-
443415
# Lists package, activity, and adb shell am start -n value for current app.
444416
# Works on local host only (not remote).
445417
def current_app

lib/appium_lib/common/helper.rb

+28
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,32 @@ def px_to_window_rel opts={}
232232
OpenStruct.new( x: x.to_f / w.width.to_f,
233233
y: y.to_f / w.height.to_f )
234234
end
235+
236+
def lazy_load_strings
237+
@strings_xml ||= mobile(:getStrings)
238+
end
239+
240+
# Search strings.xml's values for target.
241+
# @param target [String] the target to search for in strings.xml values
242+
# @return [Array]
243+
def xml_keys target
244+
lazy_load_strings
245+
@strings_xml.select { |key, value| key.downcase.include? target.downcase }
246+
end
247+
248+
# Search strings.xml's keys for target.
249+
# @param target [String] the target to search for in strings.xml keys
250+
# @return [Array]
251+
def xml_values target
252+
lazy_load_strings
253+
@strings_xml.select { |key, value| value.downcase.include? target.downcase }
254+
end
255+
256+
# Resolve id in strings.xml and return the value.
257+
# @param id [String] the id to resolve
258+
# @return [String]
259+
def resolve_id id
260+
lazy_load_strings
261+
@strings_xml[id]
262+
end
235263
end # module Appium::Common

lib/appium_lib/ios/helper.rb

-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def page_class
8383
nil
8484
end
8585

86-
def lazy_load_strings
87-
@strings_xml ||= mobile(:getStrings)
88-
end
89-
9086
# Returns a string of interesting elements. iOS only.
9187
#
9288
# Defaults to inspecting the 1st windows source only.

0 commit comments

Comments
 (0)