How to do UI automation in android?
Solution 1
You should use it like 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();
For run script use:
monkeyrunner script_name
Here is:
Click
it's function for clicking on screen in x and y position;
Drag_example
simple example of dragging
Settings_menu
simple example of running activity
Don't forget to change ANDROID_SERIAL_NUMBER
to your serial number.
You can get it nu,ber by adb devices
command.
For more information you can read google documentation.
For using in Java read this post
Solution 2
Some useful link,
Monkeyrunner: interacting with the Views Last link but best...
Solution 3
Automate is an app that can do all jobs you mentioned and many more. You wouldn't need a laptop or ADB connection. Also, no coding is required since programming is in the form of blocks and mostly synchronous.
blackfyre
Updated on August 15, 2022Comments
-
blackfyre almost 2 years
Is there any guide to do following UI automation like selecting an item, writing text, pressing buttons in Android. Please list the steps to integrated this UI automation of one of the above thing.
Thanks