@@ -151,6 +151,36 @@ def background_app(duration)
151151 end
152152 end
153153
154+ # @!method start_activity
155+ # Start a new activity within the current app or launch a new app and start the target activity.
156+ #
157+ # Android only.
158+ # @param [String] The package owning the activity [required]
159+ # @param [String] The target activity [required]
160+ # @param [String] The package to start before the target package [optional]
161+ # @param [String] The activity to start before the target activity [optional]
162+ #
163+ # ```ruby
164+ # start_activity app_package: 'io.appium.android.apis', app_activity: '.accessibility.AccessibilityNodeProviderActivity'
165+ # ```
166+ add_endpoint_method ( :start_activity , 'session/:session_id/appium/device/start_activity' ) do
167+ def start_activity ( opts )
168+ raise 'opts must be a hash' unless opts . is_a? Hash
169+ app_package = opts [ :app_package ]
170+ raise 'app_package is required' unless app_package
171+ app_activity = opts [ :app_activity ]
172+ raise 'app_activity is required' unless opts [ :app_activity ]
173+ app_wait_package = opts . fetch ( :app_wait_package , '' )
174+ app_wait_activity = opts . fetch ( :app_wait_activity , '' )
175+
176+ unknown_opts = opts . keys - [ :app_package , :app_activity , :app_wait_package , :app_wait_activity ]
177+ raise "Unknown options #{ unknown_opts } " unless unknown_opts . empty?
178+
179+ execute :start_activity , { } , { appPackage : app_package , appActivity : app_activity ,
180+ appWaitPackage : app_wait_package , appWaitActivity : app_wait_activity }
181+ end
182+ end
183+
154184 add_endpoint_method ( :set_context , 'session/:session_id/context' ) do
155185 def set_context ( context = null )
156186 execute :set_context , { } , :name => context
0 commit comments