Damia Fuentes
Damia Fuentes

Reputation: 5503

Android programmatically automated touch events

I was wondering if there is any way to progam automated touch events? For example, I have my android app and I want to make a program where automatically make 100 tests and every test makes touch events depending on what appears on the app. And I would like to do this on emulators, if is possible all 100 test at the same time.

Upvotes: 1

Views: 1790

Answers (1)

piotrek1543
piotrek1543

Reputation: 19351

for exercising your app with many (more than 100 events) use monkey (Full name: UI/Application Exerciser Monkey) or/and monkeyrunner.

The Monkey is a command-line tool that you can run on any emulator instance or on a device. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing.

The Monkey includes a number of options, but they break down into four primary categories:

Basic configuration options, such as setting the number of events to attempt.

  • Operational constraints, such as restricting the test to a single package.
  • Event types and frequencies.
  • Debugging options.

Site: http://developer.android.com/intl/es/tools/help/monkey.html

Basic using:

$ adb shell monkey [options] <event-count>

Example

adb shell monkey -p your.package.name -v 500

So if you want to take control over Android system events and you're familiar with Python and writing testing scripts, then you can use monkeyrunner.

The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code.

With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation.

The monkeyrunner tool is primarily designed to test applications and devices at the functional/framework level and for running unit test suites, but you are free to use it for other purposes.

Documentation: http://developer.android.com/intl/es/tools/help/monkeyrunner_concepts.html

NOTE: The monkeyrunner tool is not related to the I/Application Exerciser Monkey, also known as the monkey tool. The monkey tool runs in an adb shell directly on the device or emulator and generates pseudo-random streams of user and system events. In comparison, the monkeyrunner tool controls devices and emulators from a workstation by sending specific commands and events from an API.

Upvotes: 1

Related Questions