Skip to content

Commit fcc8308

Browse files
committed
Merge pull request #67 from appium/isaac-startactivity
Fix start_activity
2 parents 07a6faf + b16a9cc commit fcc8308

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

appium/webdriver/webdriver.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def close_app(self):
519519
self.execute(Command.CLOSE_APP)
520520
return self
521521

522-
def start_activity(self, app_package, app_activity, app_wait_package='', app_wait_activity=''):
522+
def start_activity(self, app_package, app_activity, **opts):
523523
"""Opens an arbitrary activity during a test. If the activity belongs to
524524
another application, that application is started and the activity is opened.
525525
@@ -528,15 +528,30 @@ def start_activity(self, app_package, app_activity, app_wait_package='', app_wai
528528
:Args:
529529
- app_package - The package containing the activity to start.
530530
- app_activity - The activity to start.
531-
- app_wait_package - Begin automation after this package starts.
532-
- app_wait_activity - Begin automation after this activity starts.
531+
- app_wait_package - Begin automation after this package starts (optional).
532+
- app_wait_activity - Begin automation after this activity starts (optional).
533+
- intent_action - Intent to start (optional).
534+
- intent_category - Intent category to start (optional).
535+
- intent_flags - Flags to send to the intent (optional).
536+
- optional_intent_arguments - Optional arguments to the intent (optional).
537+
- stop_app_on_reset - Should the app be stopped on reset (optional)?
533538
"""
534539
data = {
535540
'appPackage': app_package,
536-
'appActivity': app_activity,
537-
'appWaitPackage': app_wait_package,
538-
'appWaitActivity': app_wait_activity
541+
'appActivity': app_activity
539542
}
543+
arguments = {
544+
'app_wait_package': 'appWaitPackage',
545+
'app_wait_activity': 'appWaitActivity',
546+
'intent_action': 'intentAction',
547+
'intent_category': 'intentCategory',
548+
'intent_flags': 'intentFlags',
549+
'optional_intent_arguments': 'optionalIntentArguments',
550+
'stop_app_on_reset': 'stopAppOnReset'
551+
}
552+
for key in arguments.iterkeys():
553+
if opts.has_key(key):
554+
data[arguments[key]] = opts[key]
540555
self.execute(Command.START_ACTIVITY, data)
541556
return self
542557

test/functional/android/appium_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,21 @@ def test_send_keys(self):
191191
self.assertEqual('original text and new text', el.text)
192192

193193
def test_start_activity_this_app(self):
194-
self.driver.start_activity("io.appium.android.apis", ".ApiDemos")
194+
self.driver.start_activity("com.example.android.apis", ".ApiDemos")
195195
self._assert_activity_contains('Demos')
196196

197-
self.driver.start_activity("io.appium.android.apis", ".accessibility.AccessibilityNodeProviderActivity")
197+
self.driver.start_activity("com.example.android.apis", ".accessibility.AccessibilityNodeProviderActivity")
198198
self._assert_activity_contains('Node')
199199

200200
def test_start_activity_other_app(self):
201-
self.driver.start_activity("io.appium.android.apis", ".ApiDemos")
201+
self.driver.start_activity("com.example.android.apis", ".ApiDemos")
202202
self._assert_activity_contains('Demos')
203203

204204
self.driver.start_activity("com.android.contacts", ".ContactsListActivity")
205205
self._assert_activity_contains('Contact')
206206

207207
def _assert_activity_contains(self, activity):
208-
current = self.driver.current_activity()
208+
current = self.driver.current_activity
209209
self.assertTrue(activity in current)
210210

211211
def test_get_settings(self):

0 commit comments

Comments
 (0)