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

JohnHardmanJohnHardman John HardmanGBUniversity ✭✭✭✭✭

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

Answers

  • JohnHardmanJohnHardman John Hardman GBUniversity ✭✭✭✭✭
    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 Robert Takefman 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 http://prntscr.com/cjxc48
    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- Bart De Keersmaeker 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 John Hardman GBUniversity ✭✭✭✭✭

    @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- Bart De Keersmaeker 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 John Hardman GBUniversity ✭✭✭✭✭

    @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.

Sign In or Register to comment.