Skip to content

Commit 95c5c3c

Browse files
Current app is only for Android
1 parent 460699c commit 95c5c3c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/appium_lib/android/helper.rb

+11
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,15 @@ def xml_values target
403403
def resolve_id id
404404
mobile :resolveId, id
405405
end
406+
407+
# Lists package, activity, and adb shell am start -n value for current app.
408+
# Works on local host only (not remote).
409+
def current_app
410+
line = `adb shell dumpsys window windows`.each_line.grep(/mFocusedApp/).first.strip
411+
pair = line.split(' ').last.gsub('}','').split('/')
412+
OpenStruct.new line: line,
413+
package: pair.first,
414+
activity: pair.last,
415+
am_start: pair.first + '/' + pair.last
416+
end
406417
end # module Appium::Android

lib/appium_lib/common/helper.rb

-11
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,4 @@ def find_names name
216216
def tag tag_name
217217
find_element :tag_name, tag_name
218218
end
219-
220-
# Lists package, activity, and adb shell am start -n value for current app.
221-
# Works on local host only (not remote).
222-
def current_app
223-
line = `adb shell dumpsys window windows`.each_line.grep(/mFocusedApp/).first.strip
224-
pair = line.split(' ').last.gsub('}','').split('/')
225-
OpenStruct.new line: line,
226-
package: pair.first,
227-
activity: pair.last,
228-
am_start: pair.first + '/' + pair.last
229-
end
230219
end # module Appium::Common

0 commit comments

Comments
 (0)