Navigate to Activities
Learn how to navigate to Android activities with BELLATRIX mobile module.
Example
[TestFixture]
[Android(Constants.AndroidNativeAppPath,
Constants.AndroidDefaultAndroidVersion,
Constants.AndroidDefaultDeviceName,
Constants.AndroidNativeAppAppExamplePackage,
".view.Controls1",
Lifecycle.ReuseIfStarted)]
public class NavigateToActivitiesTests : AndroidTest
{
[Test]
public void PromotionsPageOpened_When_PromotionsButtonClicked()
{
App.AppService.StartActivity(Constants.AndroidNativeAppAppExamplePackage, ".view.Controls1");
var button = App.Components.CreateByIdContaining<Button>("button");
button.Click();
}
}
Explanations
[Android(Constants.AndroidNativeAppPath,
Constants.AndroidDefaultAndroidVersion,
Constants.AndroidDefaultDeviceName,
Constants.AndroidNativeAppAppExamplePackage,
".view.Controls1",
Lifecycle.ReuseIfStarted)]
Depending on the types of tests you want to write there are a couple of ways to navigate to а specific activity. If you use the Android attribute the first time the app is started it navigates to the specified activity.
App.AppService.StartActivity(Constants.AndroidNativeAppAppExamplePackage, ".view.Controls1");
You can always navigate in each separate tests, but if all of them open the same activity, you can use the above techniques for code reuse.