Xamarin UI Test -return to app after app.Invoke

ZenDroidZenDroid ✭✭✭USMember ✭✭✭

I created Android app with Xamarin Forms. I use Xamarin UI Test for testing life cycle app. I need events for app - OnStart, OnSleep, OnResume. My algorithm: 1. Start test, check UI (OnStart). 2. App goes to the background(OnSleep). For this I use this code:

in Activity

  [Export("GoOut")]
  public void GoOut()
  {
     var uri = Uri.Parse("http://www.google.ru");
     var intent = new Intent(Intent.ActionView, uri);
     StartActivity(intent);
  }

in Test

 app.Invoke("GoOut");

It work. Now I need to go back to the app. I want to trigger an event OnResume and testing my app. How to do it?

I tried this:

app.Invoke("GoOut");
app.Back();

and this

 //in Activity  
 [Export("Back")]
 public void Back()
 {
    this.OnBackPressed();
 }

//in my test
app.Invoke("GoOut");
app.Invoke("Back");

But it not work for me.how Can I go back to the application from browser?

Posts

  • ZenDroidZenDroid ✭✭✭ USMember ✭✭✭

    It is work:

    ConfigureApp.Android.StartApp(AppDataMode.DoNotClear);

Sign In or Register to comment.