How to dismiss an Android "ActionSend" intent in UITest?

At one point my app opens an "ActionSend" intent using "currentActivity.StartActivity(intent)".
Within my UITest i also want to test the steps after this, so i need to "dismiss" this intent, like "Press the 'Back' Button, when the 'Choose your application to send this' is appearing".

But all my attempts were in vain. I tried:

  • pressing Back button using app.Back() -> Resulting in: "Error while performing Back Injecting to another application requires INJECT_EVENTS permission". I guess this is because my test app(not the app getting tested, but the "app" performinh the test itself) hasn't that particular permission. How can i add it?
  • Using app.Tap / DoubleTap to tap "in the Background" to dismiss the intent. But this doens't seem to get caught by the intent, but by my app instead, so it's having no effect.

Anybody has an idea, what else i can try or a solution for the missing permission?

Note: i only tried on Android.

Sign In or Register to comment.