Skip to content

Commit 683ae29

Browse files
Add current_app
1 parent e8a0110 commit 683ae29

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/appium_lib/common/helper.rb

+9
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,13 @@ 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
224+
puts line
225+
pair = line.split(' ').last.gsub('}','').split('/')
226+
{ package: pair.first, activity: pair.last, am_start: pair.first + '/' + pair.last }
227+
end
219228
end # module Appium::Common

0 commit comments

Comments
 (0)