Forum Xamarin Test Cloud (Read Only)
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to press the up button on the navbar rather than the back button?

When running tests, I need to differentiate between the back button and the nav bar's up button (the left chevron or left arrow).

How can I explicitly press the up button from a UITest? Is adding a backdoor in the app and invoking that the only way?

Many thanks,

John H.

Best Answer


  • JohnHardmanJohnHardman GBUniversity admin
    edited August 2015

    @DavidLavender - Many thanks. Sorry, I should have spotted that - my brain was working on the assumption that as there was a Back() method, there might be an Up() method.

    I did have to make one slight tweak - in the Xamarin.Forms app that I am working on, the up button shows up as "up" rather than "upbutton" on Android.

  • RobertTakefmanRobertTakefman USMember ✭✭
    edited September 2016

    From the 'Share with' overlay screen, I'm trying to press the back button i,e. app.Back() but it fails. Here's the screenshot
    Any suggestions?

    Error while performing Back()
    Exception: System.Exception: PressKey for keycode:'KEYCODE_BACK' was unsucessful: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
       at Xamarin.UITest.Android.AndroidGestures.PressKey(String keycode)
       at Xamarin.UITest.Utils.ErrorReporting.With(Action func, Object[] args, String memberName)
  • Bartdk-Bartdk- USUniversity ✭✭

    Having the same issue.
    Several tests open an external application, and I'm unable to get back to our application again.
    Is there any API available to go back to our own application ?

  • JohnHardmanJohnHardman GBUniversity admin

    @Bartdk- - To get back to your app from an external app, just use StartApp again. If your app isn't running it will be re-started, if it is running it will be brought to the foreground.

  • Bartdk-Bartdk- USUniversity ✭✭

    @JohnHardman : Thanks for the tip.
    It seems like the app will not be brought to the foreground, nor will it be re-started. During my test, the application did an entire re-install ? Is there any other call for StartApp that I'm missing ? (now calling : AppInitializer.StartApp(_platform))

    Would be very nice if we could trigger an App.Device.Back instead

  • JohnHardmanJohnHardman GBUniversity admin

    @Bartdk- - I haven't looked at that bit of my code for a while, but when I was using Xamarin.UITest (I'm not any more, until it supports Windows platforms as well) I used StartApp to re-start the app or to re-foreground it. It definitely didn't do a re-install. All of my testing was done using physical devices though - I don't know if StartApp behaves differently in TestCloud.

  • AvinashVishwakumarAvinashVishwakumar USMember
    edited June 2017

    On launch, app opens a browser. (a defect at the moment which will be addressed)

    When I do an app.back(), it doesnt seem to do anything.
    If I do StartApp(), it seems to relaunch the app - leading to the same outcome.

    Any thoughts?

  • AleksandrSmykAleksandrSmyk USUniversity ✭✭

    app.Back() also doesn't work for me in test cloud. Any ideas?

  • AnthonyMehallelAnthonyMehallel USMember ✭✭✭

    Hi @AleksandrSmyk ,

    What is your Xamarin.UITest Version ? (

    app.Back() works only for Android.


  • AleksandrSmykAleksandrSmyk USUniversity ✭✭

    @AnthonyMehallel I found a decision using tapCoordinates.

  • ros_vizros_viz Member ✭✭

    I have a similar issue: I'm creating the test for my app. During the test a go to gallery and then go back to app, but app.Back() doesn't work. Help please!

Sign In or Register to comment.