Search code examples
androidautomated-testsfunctional-testingcalabash-android

calabash-android: INJECT_EVENTS permission (RuntimeError) when executing press_back_button


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



Solution

  • 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.