Click back button on android device in Java


#1

I can’t seem to find the code that works yet. Anyone, can you share Click back button on android device in Java code that works?

Thanks in advance.


#2

driver.pressKeyCode(AndroidKeyCode.BACK);


#3

It worked perfect! Thank you!


#4

For future reference, I look at the source code on github

After that, I ust searched through the repo for “back”


#5

working thanks…


#6

driver.navigate().back();


#7

While the keycode was deprecated. this worked for me. Thanks


#8

Use
driver.pressKey(new KeyEvent(AndroidKey.BACK));

Imports
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;


#9

Yes. this worked perfectly for me. the earlier one showed as a deprecated one.
Thanks for the help.