编程语言
首页 > 编程语言> > android – 如何在Robotium中重新启动已关闭的应用程序?

android – 如何在Robotium中重新启动已关闭的应用程序?

作者:互联网

我开始自动化我的Android应用.它有一个“条款和条件”屏幕.在那,如果我点击“拒绝”,我的应用程序将被关闭.

如何在同一过程中重新启动或重新启动我的应用程序?

解决方法:

尝试这个:

// assuming this method is in a ActivityInstrumentationTestCase2 class
public void test_yourTest() {

    // do your testing

    Solo.sleep(1000);

    // killing all your Activities manually if it doesn't by itself anyway
    Solo.finishOpenedActivities();

    // relaunch your app by calling the same Activity as in the constructor
    // of your ActivityInstrumentationTestCase2
    this.launchActivity(TARGET_PACKAGE_ID, YourStartActivity.class, null);

    Solo.sleep(1000);

    // do your testing
}

标签:robotium,android
来源: https://codeday.me/bug/20191008/1872811.html