How to do user interface automation in Android?

Is there any guidance for performing user interface automation, for example, for selecting an item, entering text, pressing buttons on Android. Please list the steps to integrate this automation of the user interface into one of the above tasks.

thanks

+4
source share
2 answers

You should use it as a python script. Example:

 import sys import os import time import shlex import subprocess from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice device = MonkeyRunner.waitForConnection(99, ANDROID_SERIAL_NUMBER) def Click(device, left, top, duration = 0): if duration == 0: device.touch(left, top, MonkeyDevice.DOWN_AND_UP) else: device.touch(left, top, MonkeyDevice.DOWN) time.sleep(duration) device.touch(left, top, MonkeyDevice.UP) def Drag_example(): device.drag((100, 200), (1500, 150), 1, 10) def Settings_menu(): package='com.android.settings' activity='.Settings' component_name=package + "/" + activity device.startActivity(component=component_name) Settings_menu(); 

To run the script use: monkeyrunner script_name

Here: Click function to click on the screen in x and y positions; Drag_example simple drag and drop example Settings_menu simple drag and drop operation

Remember to change ANDROID_SERIAL_NUMBER to your serial number.
You can get the nu, ber command with the adb devices command.

For more information, you can read the Google documentation .

For use in Java read this post.

+6
source

Source: https://habr.com/ru/post/1434821/


All Articles