2
Action 'press_key' unsuccessful: java.lang.SecurityException:
Injecting to another application requires INJECT_EVENTS permission (RuntimeError)

That is the error I receive when Calabash encounters the press_back_button command in a step definition. It works perfectly fine when executed through the console but generates that error in the test.

Can anyone help?


OS: OS X 10.10

Device: Genymotion v2.3.1 Android v4.4 emulation

calabash-android v0.5.5


Noffica
  • 469
  • 8
  • 23

1 Answers1

8

I had a similar problem. I don't know if this could solve yours:

I wanted to touch a button but got the same exception as you. It worked perfectly in the console.

I then realized that my test was entering text into a text field and the button was obstructed by the virtual keyboard. I was still able to query the button state but when I wanted to press it, i got the exception, probably because it tries from another application (the virtual keyboard) to interact with the button of my app.

Before pressing the button I had to execute hide_soft_keyboard

In your case, probably something else is obstructing or blocking your app. You could also make a sleep 2 to wait for other operations to complete and then pressing the button.

saxos
  • 2,467
  • 1
  • 20
  • 21
  • Quite right. There was indeed an obstruction. A previous step was failing causing the app to quit two seconds later. This two-second delay gave me the impression that it was the `press_back_button` that was the cause. – Noffica Jan 16 '15 at 17:27