diff --git a/docs/The-starting-of-an-Android-app.md b/docs/The-starting-of-an-Android-app.md
index 3edad343e..bca62fc55 100644
--- a/docs/The-starting-of-an-Android-app.md
+++ b/docs/The-starting-of-an-Android-app.md
@@ -103,6 +103,7 @@ use Android-specific API eventually.
```java
import io.appium.java_client.android.StartsActivity;
+ import io.appium.java_client.android.Activity;
...
@@ -118,7 +119,10 @@ StartsActivity startsActivity = new StartsActivity() {
}
};
-StartsActivity startsActivity.startActivity("your.package.name", ".ActivityName");
+Activity activity = new Activity("app package goes here", "app activity goes here");
+activity.setWaitAppPackage("app wait package goes here");
+activity.setWaitAppActivity("app wait activity goes here");
+StartsActivity startsActivity.startActivity(activity);
```
_Samples of the searching by AndroidUIAutomator using_ ```io.appium.java_client.AppiumDriver```
@@ -149,4 +153,4 @@ findsByAndroidUIAutomator.findElementByAndroidUIAutomator("automatorString");
driver.findElement(MobileBy.AndroidUIAutomator("automatorString"));
```
-All that ```AndroidDriver``` can do by design.
\ No newline at end of file
+All that ```AndroidDriver``` can do by design.
diff --git a/src/main/java/io/appium/java_client/android/Activity.java b/src/main/java/io/appium/java_client/android/Activity.java
new file mode 100644
index 000000000..ba7236424
--- /dev/null
+++ b/src/main/java/io/appium/java_client/android/Activity.java
@@ -0,0 +1,188 @@
+package io.appium.java_client.android;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+
+/**
+ * This is a simple POJO class to support the {@link StartsActivity}.
+ */
+public class Activity {
+ private final String appPackage;
+ private final String appActivity;
+ private String appWaitPackage;
+ private String appWaitActivity;
+ private String intentAction;
+ private String intentCategory;
+ private String intentFlags;
+ private String optionalIntentArguments;
+ private boolean stopApp;
+
+ /**
+ * A constructor with two mandatory parameters.
+ *
+ * @param appPackage The value for the app package.
+ * @param appActivity The value for the app activity.
+ */
+ public Activity(String appPackage, String appActivity) {
+ checkArgument(!isBlank(appPackage),
+ "App package should be defined as not empty or null string");
+ checkArgument(!isBlank(appActivity),
+ "App activity should be defined as not empty or null string");
+ this.appPackage = appPackage;
+ this.appActivity = appActivity;
+ this.stopApp = true;
+ }
+
+ /**
+ * Gets the app package value.
+ *
+ * @return The app package value.
+ */
+ public String getAppPackage() {
+ return appPackage;
+ }
+
+ /**
+ * Gets the app activity value.
+ *
+ * @return The app activity value.
+ */
+ public String getAppActivity() {
+ return appActivity;
+ }
+
+ /**
+ * Gets the app wait package value.
+ *
+ * @return The app wait package value.
+ */
+ public String getAppWaitPackage() {
+ return appWaitPackage;
+ }
+
+ /**
+ * Sets the app wait package value.
+ *
+ * @param appWaitPackage The app wait package value.
+ */
+ public void setAppWaitPackage(String appWaitPackage) {
+ this.appWaitPackage = appWaitPackage;
+ }
+
+ /**
+ * Gets the app wait activity value.
+ *
+ * @return The app wait activity value.
+ */
+ public String getAppWaitActivity() {
+ return appWaitActivity;
+ }
+
+ /**
+ * Sets the app wait activity value.
+ *
+ * @param appWaitActivity The app wait activity value.
+ */
+ public void setAppWaitActivity(String appWaitActivity) {
+ this.appWaitActivity = appWaitActivity;
+ }
+
+ /**
+ * Gets the intent action value.
+ *
+ * @return The intent action value.
+ */
+ public String getIntentAction() {
+ return intentAction;
+ }
+
+ /**
+ * Sets the intent action value.
+ *
+ * @param intentAction The intent action value.
+ */
+ public void setIntentAction(String intentAction) {
+ this.intentAction = intentAction;
+ }
+
+ /**
+ * Gets the intent category value.
+ *
+ * @return The intent category value.
+ */
+ public String getIntentCategory() {
+ return intentCategory;
+ }
+
+ /**
+ * Sets the intent category value.
+ *
+ * @param intentCategory The intent category value.
+ */
+ public void setIntentCategory(String intentCategory) {
+ this.intentCategory = intentCategory;
+ }
+
+ /**
+ * Gets the intent flags value.
+ *
+ * @return The intent flags value.
+ */
+ public String getIntentFlags() {
+ return intentFlags;
+ }
+
+ /**
+ * Sets the intent flags value.
+ *
+ * @param intentFlags The intent flags value.
+ */
+ public void setIntentFlags(String intentFlags) {
+ this.intentFlags = intentFlags;
+ }
+
+ /**
+ * Gets the optional intent arguments value.
+ *
+ * @return The optional intent arguments value.
+ */
+ public String getOptionalIntentArguments() {
+ return optionalIntentArguments;
+ }
+
+ /**
+ * Sets the optional intent arguments value.
+ *
+ * @param optionalIntentArguments The optional intent arguments value.
+ */
+ public void setOptionalIntentArguments(String optionalIntentArguments) {
+ this.optionalIntentArguments = optionalIntentArguments;
+ }
+
+ /**
+ * Gets the stop app value.
+ *
+ * @return The stop app value.
+ */
+ public boolean isStopApp() {
+ return stopApp;
+ }
+
+ /**
+ * Sets the stop app value.
+ *
+ * @param stopApp The stop app value.
+ */
+ public void setStopApp(boolean stopApp) {
+ this.stopApp = stopApp;
+ }
+
+ @Override public String toString() {
+ return "Activity{" + "appPackage='" + appPackage + '\'' + ", appActivity='" + appActivity
+ + '\'' + ", appWaitPackage='" + appWaitPackage + '\'' + ", appWaitActivity='"
+ + appWaitActivity + '\'' + ", intentAction='" + intentAction + '\''
+ + ", intentCategory='" + intentCategory + '\'' + ", intentFlags='" + intentFlags + '\''
+ + ", optionalIntentArguments='" + optionalIntentArguments + '\'' + ", stopApp="
+ + stopApp + '}';
+ }
+}
diff --git a/src/main/java/io/appium/java_client/android/StartsActivity.java b/src/main/java/io/appium/java_client/android/StartsActivity.java
index 46ea81f30..05b31603c 100644
--- a/src/main/java/io/appium/java_client/android/StartsActivity.java
+++ b/src/main/java/io/appium/java_client/android/StartsActivity.java
@@ -23,6 +23,31 @@
import io.appium.java_client.ExecutesMethod;
public interface StartsActivity extends ExecutesMethod {
+ /**
+ * This method should start arbitrary activity during a test. If the activity belongs to
+ * another application, that application is started and the activity is opened.
+ *
+ * Usage:
+ *
+ *
+ * {@code
+ * Activity activity = new Activity("app package goes here", "app activity goes here");
+ * activity.setWaitAppPackage("app wait package goes here");
+ * activity.setWaitAppActivity("app wait activity goes here");
+ * driver.startActivity(activity);
+ * }
+ *
+ *
+ * @param activity The {@link Activity} object
+ */
+ default void startActivity(Activity activity) {
+ CommandExecutionHelper.execute(this,
+ startActivityCommand(activity.getAppPackage(), activity.getAppActivity(),
+ activity.getAppWaitPackage(), activity.getAppWaitActivity(),
+ activity.getIntentAction(), activity.getIntentCategory(), activity.getIntentFlags(),
+ activity.getOptionalIntentArguments(), activity.isStopApp()));
+ }
+
/**
* This method should start arbitrary activity during a test. If the activity belongs to
* another application, that application is started and the activity is opened.
@@ -32,7 +57,9 @@ public interface StartsActivity extends ExecutesMethod {
* @param appWaitPackage Automation will begin after this package starts. [Optional]
* @param appWaitActivity Automation will begin after this activity starts. [Optional]
* @param stopApp If true, target app will be stopped. [Optional]
+ * @deprecated Instead use {@link #startActivity(Activity)}
*/
+ @Deprecated
default void startActivity(String appPackage, String appActivity, String appWaitPackage,
String appWaitActivity, boolean stopApp) throws IllegalArgumentException {
this.startActivity(appPackage,appActivity,appWaitPackage,
@@ -47,7 +74,9 @@ default void startActivity(String appPackage, String appActivity, String appWait
* @param appActivity The activity to start. [Required]
* @param appWaitPackage Automation will begin after this package starts. [Optional]
* @param appWaitActivity Automation will begin after this activity starts. [Optional]
+ * @deprecated Instead use {@link #startActivity(Activity)}
*/
+ @Deprecated
default void startActivity(String appPackage, String appActivity, String appWaitPackage,
String appWaitActivity) throws IllegalArgumentException {
this.startActivity(appPackage, appActivity,
@@ -60,7 +89,9 @@ default void startActivity(String appPackage, String appActivity, String appWait
*
* @param appPackage The package containing the activity. [Required]
* @param appActivity The activity to start. [Required]
+ * @deprecated Instead use {@link #startActivity(Activity)}
*/
+ @Deprecated
default void startActivity(String appPackage, String appActivity) throws IllegalArgumentException {
this.startActivity(appPackage, appActivity, null, null,
null,null,null,null,true);
@@ -79,7 +110,9 @@ default void startActivity(String appPackage, String appActivity) throws Illegal
* @param intentFlags Flags that will be used to start activity [Optional]
* @param intentOptionalArgs Additional intent arguments that will be used to
* start activity [Optional]
+ * @deprecated Instead use {@link #startActivity(Activity)}
*/
+ @Deprecated
default void startActivity(String appPackage, String appActivity,
String appWaitPackage, String appWaitActivity,
String intentAction, String intentCategory,
@@ -104,7 +137,9 @@ default void startActivity(String appPackage, String appActivity,
* @param optionalIntentArguments Additional intent arguments that will be used to
* start activity [Optional]
* @param stopApp If true, target app will be stopped. [Optional]
+ * @deprecated Instead use {@link #startActivity(Activity)}
*/
+ @Deprecated
default void startActivity(String appPackage, String appActivity, String appWaitPackage,
String appWaitActivity, String intentAction,
String intentCategory, String intentFlags,
diff --git a/src/test/java/io/appium/java_client/android/AndroidAbilityToUseSupplierTest.java b/src/test/java/io/appium/java_client/android/AndroidAbilityToUseSupplierTest.java
index 685d5d9b6..b0b2409d5 100644
--- a/src/test/java/io/appium/java_client/android/AndroidAbilityToUseSupplierTest.java
+++ b/src/test/java/io/appium/java_client/android/AndroidAbilityToUseSupplierTest.java
@@ -30,7 +30,8 @@ public class AndroidAbilityToUseSupplierTest extends BaseAndroidTest {
.waitAction(2000).moveTo(driver.findElementByAccessibilityId("Auto Complete")).release();
@Test public void horizontalSwipingWithSupplier() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.Gallery1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Gallery1");
+ driver.startActivity(activity);
AndroidElement gallery = driver.findElementById("io.appium.android.apis:id/gallery");
List images = gallery
.findElementsByClassName("android.widget.ImageView");
diff --git a/src/test/java/io/appium/java_client/android/AndroidActivityTest.java b/src/test/java/io/appium/java_client/android/AndroidActivityTest.java
index c130e0b65..706b282f0 100644
--- a/src/test/java/io/appium/java_client/android/AndroidActivityTest.java
+++ b/src/test/java/io/appium/java_client/android/AndroidActivityTest.java
@@ -24,40 +24,49 @@
public class AndroidActivityTest extends BaseAndroidTest {
@Before public void setUp() throws Exception {
- driver.startActivity("io.appium.android.apis", ".ApiDemos");
+ Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
+ driver.startActivity(activity);
}
@Test public void startActivityInThisAppTestCase() {
- driver.startActivity("io.appium.android.apis",
+ Activity activity = new Activity("io.appium.android.apis",
".accessibility.AccessibilityNodeProviderActivity");
+ driver.startActivity(activity);
assertEquals(driver.currentActivity(),
".accessibility.AccessibilityNodeProviderActivity");
}
@Test public void startActivityWithWaitingAppTestCase() {
- driver.startActivity("io.appium.android.apis",
- ".accessibility.AccessibilityNodeProviderActivity",
- "io.appium.android.apis", ".accessibility.AccessibilityNodeProviderActivity");
+ final Activity activity = new Activity("io.appium.android.apis",
+ ".accessibility.AccessibilityNodeProviderActivity");
+ activity.setAppWaitPackage("io.appium.android.apis");
+ activity.setAppWaitActivity(".accessibility.AccessibilityNodeProviderActivity");
+ driver.startActivity(activity);
assertEquals(driver.currentActivity(),
".accessibility.AccessibilityNodeProviderActivity");
}
@Test public void startActivityInNewAppTestCase() {
- driver.startActivity("com.android.contacts", ".ContactsListActivity");
+ Activity activity = new Activity("com.android.contacts", ".ContactsListActivity");
+ driver.startActivity(activity);
assertEquals(driver.currentActivity(), ".ContactsListActivity");
driver.pressKeyCode(AndroidKeyCode.BACK);
assertEquals(driver.currentActivity(), ".ContactsListActivity");
}
@Test public void startActivityInNewAppTestCaseWithoutClosingApp() {
- driver.startActivity("io.appium.android.apis",
+ Activity activity = new Activity("io.appium.android.apis",
".accessibility.AccessibilityNodeProviderActivity");
+ driver.startActivity(activity);
assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity");
- driver.startActivity("com.android.contacts", ".ContactsListActivity",
- "com.android.contacts", ".ContactsListActivity", false);
+
+ Activity newActivity = new Activity("com.android.contacts", ".ContactsListActivity");
+ newActivity.setAppWaitPackage("com.android.contacts");
+ newActivity.setAppWaitActivity(".ContactsListActivity");
+ newActivity.setStopApp(false);
+ driver.startActivity(newActivity);
assertEquals(driver.currentActivity(), ".ContactsListActivity");
driver.pressKeyCode(AndroidKeyCode.BACK);
- assertEquals(driver.currentActivity(),
- ".accessibility.AccessibilityNodeProviderActivity");
+ assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity");
}
}
diff --git a/src/test/java/io/appium/java_client/android/AndroidContextTest.java b/src/test/java/io/appium/java_client/android/AndroidContextTest.java
index 2002582f4..1ee5280b7 100644
--- a/src/test/java/io/appium/java_client/android/AndroidContextTest.java
+++ b/src/test/java/io/appium/java_client/android/AndroidContextTest.java
@@ -26,7 +26,8 @@
public class AndroidContextTest extends BaseAndroidTest {
@BeforeClass public static void beforeClass2() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.WebView1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.WebView1");
+ driver.startActivity(activity);
Thread.sleep(20000);
}
diff --git a/src/test/java/io/appium/java_client/android/AndroidElementTest.java b/src/test/java/io/appium/java_client/android/AndroidElementTest.java
index 00281537d..32cd82d57 100644
--- a/src/test/java/io/appium/java_client/android/AndroidElementTest.java
+++ b/src/test/java/io/appium/java_client/android/AndroidElementTest.java
@@ -29,7 +29,8 @@
public class AndroidElementTest extends BaseAndroidTest {
@Before public void setup() throws Exception {
- driver.startActivity("io.appium.android.apis", ".ApiDemos");
+ Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
+ driver.startActivity(activity);
}
@@ -55,7 +56,8 @@ public class AndroidElementTest extends BaseAndroidTest {
@Test public void replaceValueTest() {
String originalValue = "original value";
- driver.startActivity("io.appium.android.apis", ".view.Controls1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Controls1");
+ driver.startActivity(activity);
AndroidElement editElement = driver
.findElementByAndroidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")");
editElement.sendKeys(originalValue);
@@ -78,7 +80,8 @@ public class AndroidElementTest extends BaseAndroidTest {
@Test public void setValueTest() {
String value = "new value";
- driver.startActivity("io.appium.android.apis", ".view.Controls1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Controls1");
+ driver.startActivity(activity);
AndroidElement editElement = driver
.findElementByAndroidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")");
editElement.setValue(value);
diff --git a/src/test/java/io/appium/java_client/android/AndroidFunctionTest.java b/src/test/java/io/appium/java_client/android/AndroidFunctionTest.java
index 19fdd9041..ab3b5e84f 100644
--- a/src/test/java/io/appium/java_client/android/AndroidFunctionTest.java
+++ b/src/test/java/io/appium/java_client/android/AndroidFunctionTest.java
@@ -66,7 +66,8 @@ public class AndroidFunctionTest extends BaseAndroidTest {
@BeforeClass public static void startWebViewActivity() throws Exception {
if (driver != null) {
- driver.startActivity("io.appium.android.apis", ".view.WebView1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.WebView1");
+ driver.startActivity(activity);
}
}
diff --git a/src/test/java/io/appium/java_client/android/AndroidSearchingTest.java b/src/test/java/io/appium/java_client/android/AndroidSearchingTest.java
index 6b3dde8e6..3b0ef3eb2 100644
--- a/src/test/java/io/appium/java_client/android/AndroidSearchingTest.java
+++ b/src/test/java/io/appium/java_client/android/AndroidSearchingTest.java
@@ -30,7 +30,8 @@ public class AndroidSearchingTest extends BaseAndroidTest {
@Before
public void setup() throws Exception {
- driver.startActivity("io.appium.android.apis", ".ApiDemos");
+ Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
+ driver.startActivity(activity);
}
@Test public void findByAccessibilityIdTest() {
diff --git a/src/test/java/io/appium/java_client/android/AndroidTouchTest.java b/src/test/java/io/appium/java_client/android/AndroidTouchTest.java
index d1e88c797..305c7936a 100644
--- a/src/test/java/io/appium/java_client/android/AndroidTouchTest.java
+++ b/src/test/java/io/appium/java_client/android/AndroidTouchTest.java
@@ -22,7 +22,8 @@ public void setUp() throws Exception {
}
@Test public void dragNDropByElementTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.DragAndDropDemo");
+ Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
+ driver.startActivity(activity);
WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));
@@ -36,7 +37,8 @@ public void setUp() throws Exception {
}
@Test public void dragNDropByElementAndDurationTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.DragAndDropDemo");
+ Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
+ driver.startActivity(activity);
WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));
@@ -50,7 +52,8 @@ public void setUp() throws Exception {
}
@Test public void dragNDropByCoordinatesTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.DragAndDropDemo");
+ Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
+ driver.startActivity(activity);
AndroidElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
AndroidElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));
@@ -67,7 +70,8 @@ public void setUp() throws Exception {
}
@Test public void dragNDropByCoordinatesAndDurationTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.DragAndDropDemo");
+ Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
+ driver.startActivity(activity);
AndroidElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
AndroidElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));
@@ -84,7 +88,8 @@ public void setUp() throws Exception {
}
@Test public void pressByCoordinatesTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.Buttons1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
+ driver.startActivity(activity);
Point point =
driver.findElementById("io.appium.android.apis:id/button_toggle").getLocation();
new TouchAction(driver).press(point.x + 20, point.y + 30).waitAction(1000).release().perform();
@@ -93,7 +98,8 @@ public void setUp() throws Exception {
}
@Test public void pressByElementTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.Buttons1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
+ driver.startActivity(activity);
new TouchAction(driver).press(driver.findElementById("io.appium.android.apis:id/button_toggle"))
.waitAction(1000).release().perform();
assertEquals("ON" ,driver
@@ -101,7 +107,8 @@ public void setUp() throws Exception {
}
@Test public void tapActionTestByElement() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.ChronometerDemo");
+ Activity activity = new Activity("io.appium.android.apis", ".view.ChronometerDemo");
+ driver.startActivity(activity);
AndroidElement chronometer =
driver.findElementById("io.appium.android.apis:id/chronometer");
@@ -118,7 +125,8 @@ public void setUp() throws Exception {
}
@Test public void tapActionTestByCoordinates() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.ChronometerDemo");
+ Activity activity = new Activity("io.appium.android.apis", ".view.ChronometerDemo");
+ driver.startActivity(activity);
AndroidElement chronometer =
driver.findElementById("io.appium.android.apis:id/chronometer");
@@ -136,7 +144,8 @@ public void setUp() throws Exception {
}
@Test public void horizontalSwipingTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.Gallery1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Gallery1");
+ driver.startActivity(activity);
AndroidElement gallery = driver.findElementById("io.appium.android.apis:id/gallery");
List images = gallery
@@ -153,7 +162,8 @@ public void setUp() throws Exception {
}
@Test public void multiTouchTest() throws Exception {
- driver.startActivity("io.appium.android.apis", ".view.Buttons1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
+ driver.startActivity(activity);
TouchAction press = new TouchAction(driver);
press.press(driver.findElementById("io.appium.android.apis:id/button_toggle")).waitAction(1000).release();
new MultiTouchAction(driver).add(press)
diff --git a/src/test/java/io/appium/java_client/android/IntentTest.java b/src/test/java/io/appium/java_client/android/IntentTest.java
index 1e700d6a4..cc1be0f16 100644
--- a/src/test/java/io/appium/java_client/android/IntentTest.java
+++ b/src/test/java/io/appium/java_client/android/IntentTest.java
@@ -48,9 +48,12 @@ public class IntentTest {
@Test public void startActivityWithIntent() {
- driver.startActivity("com.android.mms", ".ui.ComposeMessageActivity", null, null,
- "android.intent.action.SEND", "android.intent.category.DEFAULT", "0x4000000",
- "-d \"TestIntent\" -t \"text/plain\"");
+ final Activity activity = new Activity("com.android.mms", ".ui.ComposeMessageActivity");
+ activity.setIntentAction("android.intent.action.SEND");
+ activity.setIntentCategory("android.intent.category.DEFAULT");
+ activity.setIntentFlags("0x4000000");
+ activity.setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\"");
+ driver.startActivity(activity);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
@@ -59,9 +62,12 @@ public class IntentTest {
}
@Test public void startActivityWithDefaultIntentAndDefaultCategoryWithOptionalArgs() {
- driver.startActivity("com.prgguru.android", ".GreetingActivity", null, null,
- "android.intent.action.MAIN", "android.intent.category.DEFAULT", "0x4000000",
- "--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\"");
+ final Activity activity = new Activity("com.prgguru.android", ".GreetingActivity");
+ activity.setIntentAction("android.intent.action.MAIN");
+ activity.setIntentCategory("android.intent.category.DEFAULT");
+ activity.setIntentFlags("0x4000000");
+ activity.setOptionalIntentArguments("--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\"");
+ driver.startActivity(activity);
assertEquals(driver.findElementById("com.prgguru.android:id/textView1").getText(),
"Welcome AppiumIntentTest");
}
diff --git a/src/test/java/io/appium/java_client/android/UIAutomator2Test.java b/src/test/java/io/appium/java_client/android/UIAutomator2Test.java
index 2ccd67248..de480866e 100644
--- a/src/test/java/io/appium/java_client/android/UIAutomator2Test.java
+++ b/src/test/java/io/appium/java_client/android/UIAutomator2Test.java
@@ -85,7 +85,8 @@ public class UIAutomator2Test {
@Test public void testToastMSGIsDisplayed() throws InterruptedException {
final WebDriverWait wait = new WebDriverWait(driver, 10);
- driver.startActivity("io.appium.android.apis", ".view.PopupMenu1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.PopupMenu1");
+ driver.startActivity(activity);
MobileElement popUpElement = driver.findElement(MobileBy.AccessibilityId("Make a Popup!"));
popUpElement.click();
diff --git a/src/test/java/io/appium/java_client/appium/AndroidTest.java b/src/test/java/io/appium/java_client/appium/AndroidTest.java
index 99f5668ef..b73645df4 100644
--- a/src/test/java/io/appium/java_client/appium/AndroidTest.java
+++ b/src/test/java/io/appium/java_client/appium/AndroidTest.java
@@ -7,6 +7,7 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileBy;
import io.appium.java_client.MobileElement;
+import io.appium.java_client.android.Activity;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.android.StartsActivity;
import io.appium.java_client.remote.MobileCapabilityType;
@@ -78,7 +79,8 @@ public Response execute(String driverCommand) {
return driver.execute(driverCommand);
}
};
- startsActivity.startActivity("io.appium.android.apis", ".ApiDemos");
+ Activity activity = new Activity("io.appium.android.apis", ".ApiDemos");
+ startsActivity.startActivity(activity);
}
@Test
@@ -121,7 +123,8 @@ public void findByAccessibilityIdFromDriverTest() {
@Test public void replaceValueTest() {
String originalValue = "original value";
- startsActivity.startActivity("io.appium.android.apis", ".view.Controls1");
+ Activity activity = new Activity("io.appium.android.apis", ".view.Controls1");
+ startsActivity.startActivity(activity);
AndroidElement editElement = driver
.findElement(MobileBy
.AndroidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")"));
diff --git a/src/test/java/io/appium/java_client/pagefactory_tests/widgets/AndroidOverrideWidgetTest.java b/src/test/java/io/appium/java_client/pagefactory_tests/widgets/AndroidOverrideWidgetTest.java
index ab491514c..8ac3f6f80 100644
--- a/src/test/java/io/appium/java_client/pagefactory_tests/widgets/AndroidOverrideWidgetTest.java
+++ b/src/test/java/io/appium/java_client/pagefactory_tests/widgets/AndroidOverrideWidgetTest.java
@@ -4,6 +4,7 @@
import static org.junit.Assert.assertTrue;
import io.appium.java_client.MobileElement;
+import io.appium.java_client.android.Activity;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.pagefactory.TimeOutDuration;
@@ -70,7 +71,9 @@ public static void afterClass() throws Exception {
@Before
public void setUp() throws Exception {
if (driver != null) {
- driver.startActivity("com.codepath.example.rottentomatoes", "BoxOfficeActivity");
+ Activity activity = new Activity("com.codepath.example.rottentomatoes",
+ "BoxOfficeActivity");
+ driver.startActivity(activity);
}
}
diff --git a/src/test/java/io/appium/java_client/pagefactory_tests/widgets/android/AndroidWidgetTest.java b/src/test/java/io/appium/java_client/pagefactory_tests/widgets/android/AndroidWidgetTest.java
index 714340caa..d728fba11 100644
--- a/src/test/java/io/appium/java_client/pagefactory_tests/widgets/android/AndroidWidgetTest.java
+++ b/src/test/java/io/appium/java_client/pagefactory_tests/widgets/android/AndroidWidgetTest.java
@@ -4,6 +4,7 @@
import static org.junit.Assert.assertTrue;
import io.appium.java_client.MobileElement;
+import io.appium.java_client.android.Activity;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.pagefactory.TimeOutDuration;
@@ -70,7 +71,9 @@ public static void afterClass() throws Exception {
@Before
public void setUp() throws Exception {
if (driver != null) {
- driver.startActivity("com.codepath.example.rottentomatoes", "BoxOfficeActivity");
+ Activity activity = new Activity("com.codepath.example.rottentomatoes",
+ "BoxOfficeActivity");
+ driver.startActivity(activity);
}
}
diff --git a/src/test/java/io/appium/java_client/pagefactory_tests/widgets/combined/AndroidCombinedWidgetTest.java b/src/test/java/io/appium/java_client/pagefactory_tests/widgets/combined/AndroidCombinedWidgetTest.java
index 0a7c5d220..d547ce82d 100644
--- a/src/test/java/io/appium/java_client/pagefactory_tests/widgets/combined/AndroidCombinedWidgetTest.java
+++ b/src/test/java/io/appium/java_client/pagefactory_tests/widgets/combined/AndroidCombinedWidgetTest.java
@@ -4,6 +4,7 @@
import static org.junit.Assert.assertTrue;
import io.appium.java_client.MobileElement;
+import io.appium.java_client.android.Activity;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import io.appium.java_client.pagefactory.TimeOutDuration;
@@ -70,7 +71,9 @@ public static void afterClass() throws Exception {
@Before
public void setUp() throws Exception {
if (driver != null) {
- driver.startActivity("com.codepath.example.rottentomatoes", "BoxOfficeActivity");
+ Activity activity = new Activity("com.codepath.example.rottentomatoes",
+ "BoxOfficeActivity");
+ driver.startActivity(activity);
}
}