How to automate Home,back,up,down,Menu button at bottom of Android phone using appium java client 6.1.0?

I am new to appium and trying to automate one android native app but currently I am blocked as I am not able to inspect back,Home,Active app button present at bottom of Android phone screen.

I googled a lot about it but everywhere I found use of method “pressKeyCode(int key)” but this method is currently deprecated
(https://appium.github.io/java-client/io/appium/java_client/android/nativekey/PressesKey.html)

I tried new method pressKey(KeyEvent keyEvent) but still not working.

Request to please help or let me know any reference where I can get details regarding.

PFB part of code:

AndroidDriver driver;
driver=new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), cap);

driver.pressKey(KeyEvent(KEYCODE_MENU))); // KEYCODE_MENU can not be resolved
driver.pressKey(withKey(AndroidKey.HOME)))); //The method home is undefined for the type AndroidKey.

1 Like

Thanks for help, this worked for me.