6

I am using chrome devtools to debug a site running on an android device. In an android device you usually have the "menu" button and the "back" button. How can I emulate a key press to one of these keys using chrome devtools?

Tiagojdferreira
  • 1,122
  • 2
  • 14
  • 20

1 Answers1

14

The action performed on pressing the "back" button is dependent on the context. It can be one of the two:

  1. "Back" action in the browser. You can emulate it by calling window.history.back()
  2. If there are no pages to go back to, then pressing "back" will pop the activity stack and the browser will be closed. I'm not sure how to handle this properly. There is window.close(), but it only works in conjunction with window.open(), so in order to use it the workflow would be: call window.open() -> do stuff -> call window.close().
pablochan
  • 5,625
  • 27
  • 42