Navigate back or home screen using Appium

imageedit_7_9964837647

Class AndroidDriver (implements AppiumDriver interface)  has method pressKeyCode(int key) for your handset / emulator to navigate to Home screen or navigating back.

the argument key can be any one of the option from below link
https://developer.android.com/reference/android/view/KeyEvent.html

To navigate to home screen:

Navigate to back screen:





Let’s see how we can implement in code those above 2 statements

 

Content posted is based on learning or working experience, please leave comments if anything needs to be added or updated, discuss your queries on our facebook:qavalidation.com, Thanks!

2 Responses

  1. Bharath G says:

    hi i’m using driver.pressKeyCode(AndroidKeyCode.KEYCODE_CAMERA); to click picture in camera but it’s not working

  2. sunilpatro1985 says:

    can you try this one –
    Runtime.getRuntime().exec(“cmd /C adb shell input keyevent ” + 27);

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: