The new "Start Activity" feature in Appium 1.2.3

Appium 1.2.3 has a new Android-only feature, “Start Activity.” It allows you to start an arbitrary activity at test time. If the activity is part of an application different from the application currently under test, “Start Activity” will also start the activity’s application. Nice!

The “Start Activity” feature requires two arguments, appPackage and appActivity. You can optionally provide “wait” activities via appWaitPackage and appWaitActivity, the same way you can when launching the application under test. Here’s how easy it is to start the activity “.Foo”:

Start Activity

Open an activity in the current app or start a new app and open an activity Android only

// java
driver.startActivity("appPackage","com.example.android.apis", null, null);
// javascript
driver.startActivity({appPackage: 'com.example.android.apis', appActivity: '.Foo'}, cb);
# python
driver.start_activity('com.example.android.apis', '.Foo')
# ruby
start_activity app_package: 'io.appium.android.apis', app_activity: '.accessibility.AccessibilityNodeProviderActivity'
// c#
driver.StartActivity("com.example.android.apis", ".Foo");
// php
$this->startActivity(array("appPackage" => "com.example.android.apis",
                           "appActivity" => ".Foo"));
1 Like

Note that 1.2.3 is a forthcoming release as of 9/16/14.

1 Like

hi,
It seems nice. so can we open sms inbox and read specific sms (programatically and part of automation script) while during test.

Thanks,
Priyank Shah

Yes, that should work. E.g., one of the tests I wrote for this feature opens Contacts while testing another application.

What’s the code assigned to driver?

This does not seem to work for Python 3, as there has been some changes to how dictionaries are handled. Trying to start the network selection dialog with driver.start_activity(“com.android.settings”, “.wifi.WifiSetupActivity”) results in an error being thrown.

After you check the SMS (or choose a network in my case), how do you switch back to the original app?

Hey @Priyank_Shah
i am wondering that could you read a specific sms like you mention above.

Watch “Appium Tutorial- Switching between apps (Contact …” on YouTube
Appium Tutorial- Switching between apps (Contact …: https://youtu.be/sH1bHeDDj8U

@Appium_Master Is there a way we can set a flag so on start_activity the first app is resumed from where it left instead of starting the fresh ? I am looking to find a solution in Python.