Zeev
Zeev

Reputation: 23

Android.test.TouchUtils methods don't work on headless emulator, help!

I'm trying to get my Android tests running on headless emulator for future use on CI servers. But non of the TouchUtils methods, like "clickView()" etc.. seem work this way.

I'm always getting SecurityException:

"Injecting to another application requires INJECT_EVENTS permission".

Looks like it doesn't click the right objects in the first place. In normal GUI mode everything works fine.

Is there any way around this?
If no, which setup would you recommend to run all the tests on remote machines?

Thank you!

Upvotes: 2

Views: 1058

Answers (1)

Robert
Robert

Reputation: 7053

The device is probably showing the lock screen. Check it with the hierarchyviewer or screenshot2.

You can unlock the screen by sending a menu button, for instance by using adb:

adb shell input keyevent 82

(The keyevent code can be found in android.view.KeyEvent.)

Upvotes: 4

Related Questions