I want to run monkeyrunner python script.
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
from com.android.monkeyrunner.easy import EasyMonkeyDevice
from com.android.monkeyrunner.easy import By
from modjy.modjy_params import INTEGER
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
easyDevice = EasyMonkeyDevice(device)
MonkeyRunner.sleep(2)
easyDevice.touch(By.id('id/btnSignUp'),MonkeyDevice.DOWN_AND_UP)
Below is the command I am using to run script
c:\path_to_and_sdk_tool> monkeyrunner test.py
But I am getting error when I get "EasyMonkeyDevice" Object.
File "C:\python\test.py", line 19, in <module>
easyDevice = EasyMonkeyDevice(device)
java.lang.RuntimeException: Could not connect to the view server
at com.android.chimpchat.hierarchyviewer.HierarchyViewer.setupViewServer
(HierarchyViewer.java:57)
at com.android.chimpchat.hierarchyviewer.HierarchyViewer.<init>(Hierarch
yViewer.java:43)
at com.android.chimpchat.adb.AdbChimpDevice.getHierarchyViewer(AdbChimpD
evice.java:95)
at com.android.monkeyrunner.easy.EasyMonkeyDevice.<init>(EasyMonkeyDevic
e.java:64)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.python.core.PyReflectedConstructor.make(PyReflectedConstructor.ja
va:67)
at org.python.core.PyJavaType$1.new_impl(PyJavaType.java:517)
at org.python.core.PyType.invokeNew(PyType.java:466)
at org.python.core.PyType.type___call__(PyType.java:1558)
Please share some links from where i can get EasyMonkeyDevice import
You have to implement ViewServer to use EasyMonkeyDevice : https://github.com/romainguy/ViewServer because easyMonkey uses Hierarchy Viewer.
In your activities :
Enable ViewServer for hierarchy viewer like this :