AppService
Learn how to use BELLATRIX Android AppService.
Example
[TestFixture]
public class AppServiceTests : AndroidTest
{
[Test]
public void TestBackgroundApp()
{
App.AppService.BackgroundApp(1);
}
[Test]
public void TestResetApp()
{
App.AppService.ResetApp();
}
[Test]
public void InstallAppInstalledFalse_When_AppIsUninstalled()
{
string appPath = Path.Combine(ProcessProvider.GetExecutingAssemblyFolder(), "Demos\\ApiDemos.apk");
App.AppService.InstallApp(appPath);
App.AppService.RemoveApp("com.example.android.apis");
Assert.IsFalse(App.AppService.IsAppInstalled("com.example.android.apis"));
App.AppService.InstallApp(appPath);
Assert.IsTrue(App.AppService.IsAppInstalled("com.example.android.apis"));
}
}
Explanations
BELLATRIX gives you an interface to most common operations for controlling the Android app through the AppService class. We already saw one of them StartActivity for opening a particular initial activity.
App.AppService.BackgroundApp(1);
Backgrounds the app for the specified number of seconds.
App.AppService.ResetApp();
Resets the app.
Assert.IsTrue(App.AppService.IsAppInstalled("com.example.android.apis"));
Checks whether the app with the specified app package is installed.
App.AppService.InstallApp(appPath);
Installs the APK file on the device.
App.AppService.RemoveApp("io.appium.android.apis");
Uninstalls the app with the specified app package.