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
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 draggingSettings_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
Some useful link,
Android: Sample Code To Demonstrate Monkeyrunner
Android Guide: monkeyrunner Overview
Android Guide: MonkeyDevice
Android Guide: MonkeyRunner
Monkeyrunner: interacting with the Views Last link but best...
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.
Play Store link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With