dtmilano / androidviewclient Goto Github PK
View Code? Open in Web Editor NEWAndroid ViewServer and ADB client
License: Apache License 2.0
Android ViewServer and ADB client
License: Apache License 2.0
Hi Diego,
I am new in Android development and testing and I am trying to use AndroidViewClient for the first time and I followed the steps you have and kept getting an error, could you suggest me how I solve this?
I am using Emulator and have setup ANDROID_HOME, ANDROID_VIEW_CLIENT_HOME to ..\sdk\platform-tools\ and ..\sdk\tools\AndroidViewClient
and the code I used
"import re
import sys
import os
try:
for p in os.environ['PYTHONPATH'].split(':'):
if not p in sys.path:
sys.path.append(p)
except:
pass
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.viewclient import ViewClient, ViewNotFoundException
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
from com.android.monkeyrunner.easy import EasyMonkeyDevice
from com.android.monkeyrunner.easy import By
print "Launching application again"
vc = ViewClient(*ViewClient.connectToDeviceOrExit())"
Errors which I got when running C:\Android\adt-bundle-windows-x86_6420130219\sdk\tools>monkeyrunner -plugin androidviewclient-2.3.16.jar c:\Android\SampleApps\MonkeyRunnerExample\Main.py
C:\Android\adt-bundle-windows-x86_6420130219\sdk\tools\AndroidViewClient\src\com\dtmilano\android\v
iewclient.py:1135: UserWarning: Running on emulator but no serial number was specified then 'emulator-5554' is used warnings.warn("Running on emulator but no serial number was specified then 'emulator-5554' is used")
130516 15:30:08.761:S [MainThread] com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
130516 15:30:08.761:S [MainThread][com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most rec
ent call last):
File "c:\Android\SampleApps\MonkeyRunnerExample\Main.py", line 25, in
vc = ViewClient(*ViewClient.connectToDeviceOrExit())
File "C:\Android\adt-bundle-windows-x86_64-20130219\sdk\tools\AndroidViewClient\src\com\dtmilano\a
ndroid\viewclient.py", line 958, in init
adb = ViewClient.__obtainAdbPath()
File "C:\Android\adt-bundle-windows-x86_64-20130219\sdk\tools\AndroidViewClient\src\com\dtmilano\a
ndroid\viewclient.py", line 1100, in _ViewClient__obtainAdbPath
raise Exception('adb="%s" is not executable. Did you forget to set ANDROID_HOME in the environme
nt?' % adb)
Exception: adb="adb.exe" is not executable. Did you forget to set ANDROID_HOME in the environment?
I'm trying to run some AVC scripts on Jenkins, but I can't seem to connect to the emulator created during the execution.
I turned on the DEBUG flag and ran adb devices
before executing the script, you can see the output below.
Also, ANDROID_SERIAL
is set by the Android Emulator plugin and I have tried several things to get AVC to connect to the emulator instance, including getting the ANDROID_SERIAL
variable, but I couldn't get it to work.
Any ideas?
+ adb devices
List of devices attached
localhost:51682 device
+ python screenshots.py
Connecting to a device with serialno=localhost:51682 with a timeout of 60 secs...
__connect()
checkVersion(reconnect=True)
__send(host:version, checkok=True, reconnect=False)
checkConnected()
checkConnected: returning True
__checkOk()
checkConnected()
checkConnected: returning True
setAlarm(15)
__checkOk: recv= 'OKAY'
setAlarm(0)
__checkOk: returning True
__connect()
__setTransport()
checkConnected()
checkConnected: returning True
getDevices()
__send(host:devices-l, checkok=False, reconnect=False)
checkConnected()
checkConnected: returning True
__checkOk()
checkConnected()
checkConnected: returning True
setAlarm(15)
__checkOk: recv= 'OKAY'
setAlarm(0)
__checkOk: returning True
__receive()
checkConnected()
checkConnected: returning True
__receive: receiving 0 bytes
__receive: returning len= 0
__connect()
Capturing the device
Traceback (most recent call last):
File "screenshots.py", line 150, in <module>
device, serialno = ViewClient.connectToDeviceOrExit(verbose=True)
File "/Users/knorrium/dev/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/viewclient.py", line 1383, in connectToDeviceOrExit
device = adbclient.AdbClient(serialno)
File "/Users/knorrium/dev/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 87, in __init__
self.__setTransport()
File "/Users/knorrium/dev/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 206, in __setTransport
raise RuntimeError("ERROR: couldn't find device that matches '%s'" % self.serialno)
RuntimeError: ERROR: couldn't find device that matches 'localhost:51682'
Closing socket... <socket._socketobject object at 0x105b88fa0>
Build step 'Execute shell' marked build as failure
$ /Applications/adt-bundle-mac-x86_64/sdk/platform-tools/adb disconnect localhost:51682
[android] Stopping Android emulator
[android] Archiving emulator log
$ /Applications/adt-bundle-mac-x86_64/sdk/platform-tools/adb kill-server
Looking through your adb code it appears you have not added anything for installing packages but assume they are already installed. Is there a reason you left this feature out?
Hi
I downloaded the latest viewClient but met below error.
Does any one meet that before?
File "/src/com/dtmilano/android/viewclient.py", line 1180, in init
if not self.serviceResponse(device.shell('service call window 3')):
at com.android.monkeyrunner.MonkeyDevice.shell(MonkeyDevice.java:226)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
java.lang.NullPointerException: java.lang.NullPointerException
I'm running dump-all-windows-lib.py example, but it keeps showing this error:
windows = vc.list()
File "/Users/ehsan/Desktop/Android/adt-bundle-mac-x86_64-20130514/sdk/tools/androidviewclient-2.3.24.jar/com/dtmilano/android/viewclient$py.class", line 1864, in list
Exception: Not implemented yet: listing windows with UiAutomator
I can run other examples but I don't know what is the problem. and this is how I run the example:
monkeyrunner -plugin androidviewclient-2.3.24.jar dump-all-windows-lib.py
Thanks in advance...
When I'm trying to use the AndroidViewClient under Windows XP I'm getting the following error, when trying to call ViewClient(device) from my monkeyrunner script:
File "C:\Program Files\Android\android-sdk\tools\mr_scripts\AndroidViewClient\src\com\dtmilano\android\viewclient.py", line 135, in **init**
self.assertServiceResponse(device.shell('service call window 1 i32 %d' %
File "C:\Program Files\Android\android-sdk\tools\mr_scripts\AndroidViewClient\src\com\dtmilano\android\viewclient.py", line 146, in assertServiceResponse
raise Exception('Invalid response received from service.')
Exception: Invalid response received from service.
Hi,
I noticed that if I run code on emulator and then on device I get different ids for widgets. This causes my script to fail. Also is there some trick to get ids to match up with R.id ? why do we get NO_ID in dump ?
Apart from it non-ui testing can it be done with AndroidViewClient ? I prefer doing it such that scripts run fast then is py4a better option ? usually testing is done against emulator or actual devices ?
I did not find link to mailing list so posting all here.
Regards,
Miten.
Hi,
For old Android version like 4.2 and 4.1, input swipe doesn't accept duration parameter, so I can't use drag method for these devices.
So would you like to change drag method not to use duration for old devices?
I'm not sure duration is mandatory parameter for ICS and GB, but duration is optional parameter even for 4.3.
Please let me know your opinion on this.
Thank you.
When calling takeSnapshot(), the error occurs:
Traceback (most recent call last):
File "/home/test/droid/monkey.py", line 178, in
main()
File "/home/test/droid/monkey.py", line 150, in main
takeSnapshot(device, pkgPath, idx, "%s-bc" % (""))
File "/home/test/droid/monkey.py", line 85, in takeSnapshot
img = device.takeSnapshot()
File "/home/test/droid/AndroidViewClient-4.2.1/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 323, in takeSnapshot
mode[aoffset/alen] = 'A'
ZeroDivisionError: integer division or modulo by zero
Hello,
In the android settings app, in the storage section there are two views with the same id and the same text. When i do viewclient.findViewWithText('text'), I only get the first view with that text.
The thing is, I need the second view.
Cand the view client return the second view with that text?
Hi,
I'm fresh to AndroidViewClient. When I ran dump.py on my Windows 7, I got an ImportError. Message is as below:
D:\AndroidViewClient-master\AndroidViewClient\examples>dump.py -V
Traceback (most recent call last):
File "D:\AndroidViewClient-master\AndroidViewClient\examples\dump.py", line 29
, in
from com.dtmilano.android.viewclient import ViewClient
File "D:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\v
iewclient.py", line 27, in
import java
ImportError: No module named java
I already set up the running environment, so what's wrong I got here?
Thanks very much in advance.
Hello,
I am trying to automate a test where I need to enable Bluetooth on my device. I found the view containing the switch widget:
import all the stuff here
...
package='com.android.settings'
activity='.Settings'
componentName=package + "/" + activity
device, serialno = ViewClient.connectToDeviceOrExit()
if START_ACTIVITY:
device.startActivity(component = componentName)
MonkeyRunner.sleep(3)
vc = ViewClient(device=device, serialno=serialno)
vc.dump()
view = vc.findViewWithText('Bluetooth')
for i in view.parent.parent.children:
#print str(i), '\n'
if i.getId() == 'id/switchWidget':
i['isChecked()'] = 'true'
Now, is there any way to modify the state of the switch widget? I need to modify isChecked() from false to true.
Hi, my problem is that when I try to launch a modification of some of your examples (I just launch an installed application, not even touch any button) on an mobile phone instead of the emulator, the next sequence of errors happen:
C:\adt-bundle-windows-x86_64\sdk\tools>monkeyrunner C:\devset.py
C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py:23: RuntimeWarning: Unable to deter
mine shell_command for underlying os: nt
import subprocess
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: display.height
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Software caused c
onnection abort: socket write error
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te0(Native Method)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te(SocketOutputStream.java:92)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.write(Soc
ketOutputStream.java:136)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.writeBytes(S
treamEncoder.java:202)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implFlushBuf
fer(StreamEncoder.java:272)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implFlush(St
reamEncoder.java:276)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.flush(Stream
Encoder.java:122)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.OutputStreamWriter.flush(Outp
utStreamWriter.java:212)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.BufferedWriter.flush(Buffered
Writer.java:236)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.se
ndMonkeyEventAndGetResponse(ChimpManager.java:186)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.ge
tVariable(ChimpManager.java:269)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.adb.AdbChimpDev
ice.getProperty(AdbChimpDevice.java:231)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyDevice
.getProperty(MonkeyDevice.java:103)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke0(Native Method)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke(NativeMethodAccessorImpl.java:39)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.DelegatingMethodAccessorI
mpl.invoke(DelegatingMethodAccessorImpl.java:25)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.lang.reflect.Method.invoke(Metho
d.java:597)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyReflectedFunction.
call_(PyReflectedFunction.java:175)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:355)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:215)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.instancemeth
od___call__(PyMethod.java:221)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:206)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:397)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:401)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.__
init__$53(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py:949)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.ca
ll_function(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:297)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:191)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:385)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:380)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyInstance.init(P
yInstance.java:120)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyClass.call(PyCl
ass.java:194)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:414)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:418)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode.pyx0.f$0(C:\devset
.py:42)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode.pyx0.call_function
(C:\devset.py)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyCode.call(PyCode.ja
va:18)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.Py.runCode(Py.java:11
97)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.builtin.execfile
flags(builtin.java:538)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.util.PythonInterpreter.exe
cfile(PythonInterpreter.java:156)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.ScriptRunner
.run(ScriptRunner.java:116)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.run(MonkeyRunnerStarter.java:77)
130207 10:46:37.772:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.main(MonkeyRunnerStarter.java:189)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: display.density
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Software caused c
onnection abort: socket write error
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te0(Native Method)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te(SocketOutputStream.java:92)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.write(Soc
ketOutputStream.java:136)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.writeBytes(S
treamEncoder.java:202)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implWrite(St
reamEncoder.java:263)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.write(Stream
Encoder.java:106)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.OutputStreamWriter.write(Outp
utStreamWriter.java:190)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.BufferedWriter.flushBuffer(Bu
fferedWriter.java:111)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.BufferedWriter.flush(Buffered
Writer.java:235)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.se
ndMonkeyEventAndGetResponse(ChimpManager.java:186)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.ge
tVariable(ChimpManager.java:269)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.adb.AdbChimpDev
ice.getProperty(AdbChimpDevice.java:231)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyDevice
.getProperty(MonkeyDevice.java:103)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke0(Native Method)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke(NativeMethodAccessorImpl.java:39)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.DelegatingMethodAccessorI
mpl.invoke(DelegatingMethodAccessorImpl.java:25)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.lang.reflect.Method.invoke(Metho
d.java:597)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyReflectedFunction.
call_(PyReflectedFunction.java:175)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:355)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:215)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.instancemeth
od___call__(PyMethod.java:221)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:206)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:397)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:401)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.__
init__$53(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py:949)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.ca
ll_function(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:297)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:191)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:385)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:380)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyInstance.init(P
yInstance.java:120)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyClass.call(PyCl
ass.java:194)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:414)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:418)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode.pyx0.f$0(C:\devset
.py:42)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode.pyx0.call_function
(C:\devset.py)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyCode.call(PyCode.ja
va:18)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.Py.runCode(Py.java:11
97)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.builtin.execfile
flags(builtin.java:538)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.util.PythonInterpreter.exe
cfile(PythonInterpreter.java:156)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.ScriptRunner
.run(ScriptRunner.java:116)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.run(MonkeyRunnerStarter.java:77)
130207 10:46:37.793:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.main(MonkeyRunnerStarter.java:189)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: build.version.sdk
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Software caused c
onnection abort: socket write error
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te0(Native Method)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te(SocketOutputStream.java:92)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.write(Soc
ketOutputStream.java:136)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.writeBytes(S
treamEncoder.java:202)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implWrite(St
reamEncoder.java:263)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.write(Stream
Encoder.java:106)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.OutputStreamWriter.write(Outp
utStreamWriter.java:190)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.BufferedWriter.flushBuffer(Bu
fferedWriter.java:111)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.BufferedWriter.flush(Buffered
Writer.java:235)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.se
ndMonkeyEventAndGetResponse(ChimpManager.java:186)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.ge
tVariable(ChimpManager.java:269)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.adb.AdbChimpDev
ice.getProperty(AdbChimpDevice.java:231)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyDevice
.getProperty(MonkeyDevice.java:103)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke0(Native Method)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke(NativeMethodAccessorImpl.java:39)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.DelegatingMethodAccessorI
mpl.invoke(DelegatingMethodAccessorImpl.java:25)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.lang.reflect.Method.invoke(Metho
d.java:597)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyReflectedFunction.
call_(PyReflectedFunction.java:175)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:355)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:215)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.instancemeth
od___call__(PyMethod.java:221)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:206)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:397)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:401)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.__
init__$53(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py:949)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.ca
ll_function(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:297)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:191)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:385)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:380)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyInstance.init(P
yInstance.java:120)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyClass.call(PyCl
ass.java:194)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:414)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:418)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode.pyx0.f$0(C:\devset
.py:42)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode.pyx0.call_function
(C:\devset.py)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyCode.call(PyCode.ja
va:18)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.Py.runCode(Py.java:11
97)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.builtin.execfile
flags(builtin.java:538)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.util.PythonInterpreter.exe
cfile(PythonInterpreter.java:156)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.ScriptRunner
.run(ScriptRunner.java:116)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.run(MonkeyRunnerStarter.java:77)
130207 10:46:38.017:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.main(MonkeyRunnerStarter.java:189)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: build.version.rele
ase
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Software caused c
onnection abort: socket write error
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te0(Native Method)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWri
te(SocketOutputStream.java:92)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.write(Soc
ketOutputStream.java:136)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.writeBytes(S
treamEncoder.java:202)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implWrite(St
reamEncoder.java:263)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.write(Stream
Encoder.java:106)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.OutputStreamWriter.write(Outp
utStreamWriter.java:190)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.BufferedWriter.flushBuffer(Bu
fferedWriter.java:111)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.io.BufferedWriter.flush(Buffered
Writer.java:235)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.se
ndMonkeyEventAndGetResponse(ChimpManager.java:186)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.ChimpManager.ge
tVariable(ChimpManager.java:269)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.chimpchat.adb.AdbChimpDev
ice.getProperty(AdbChimpDevice.java:231)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyDevice
.getProperty(MonkeyDevice.java:103)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke0(Native Method)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.NativeMethodAccessorImpl.
invoke(NativeMethodAccessorImpl.java:39)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at sun.reflect.DelegatingMethodAccessorI
mpl.invoke(DelegatingMethodAccessorImpl.java:25)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at java.lang.reflect.Method.invoke(Metho
d.java:597)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyReflectedFunction.
call_(PyReflectedFunction.java:175)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:355)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:215)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.instancemeth
od___call__(PyMethod.java:221)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyMethod.call(PyM
ethod.java:206)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:397)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:401)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.__
init__$53(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py:949)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.dtmilano.android.viewclient$py.ca
ll_function(C:\AndroidViewClient-master\AndroidViewClient\src\com\dtmilano\android\viewclient.py)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:297)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyBaseCode.call(PyBas
eCode.java:191)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:385)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyFunction.call(P
yFunction.java:380)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyInstance.init(P
yInstance.java:120)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyClass.call(PyCl
ass.java:194)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:414)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyObject.call(PyO
bject.java:418)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode._pyx0.f$0(C:\devset
.py:42)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.pycode.pyx0.call_function
(C:\devset.py)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyTableCode.call(PyTa
bleCode.java:165)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.PyCode.call(PyCode.ja
va:18)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.Py.runCode(Py.java:11
97)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.core.builtin.execfile
flags(builtin.java:538)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at org.python.util.PythonInterpreter.exe
cfile(PythonInterpreter.java:156)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.ScriptRunner
.run(ScriptRunner.java:116)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.run(MonkeyRunnerStarter.java:77)
130207 10:46:38.228:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] at com.android.monkeyrunner.MonkeyRunner
Starter.main(MonkeyRunnerStarter.java:189)
¿Desea terminar el trabajo por lotes (S/N)?
Hope you can help me. I use AndroidViewClient last version. Python 3.3, Windows 7. And I could try some other example succesfully on emulator with this very configuration. Thanks
If we run ruby and calabash-android when query on webview it list all elements in webview such as buttons, textboxes. Can we get such ids using dump -VF?
Hi,
i'm trying to toggle airplane mode so i simulate a long press on power button to enter the device options menu.
then i search for the "airplane mode" query to press it but it pressing the wrong x,y
i did a dump -c on the window and saw that there is offset of 200px in the y axis
i tried it on galaxy s2 & s3 version 4.1.2
I'm doing long tests using monkeyrunner and your androidviewclient and i save asserted messages when i get them, many times i get the following assert:
Traceback (most recent call last):
vc = ViewClient(device, serialno)
File "pyclasspath/dtmilano/android/viewclient.py", line 1073, in init
File "pyclasspath/dtmilano/android/viewclient.py", line 1638, in dump
RuntimeError: ERROR: Getting UIAutomator dump
my program that i wrote resets the adb server when it happens and it continue to run as normal so I don't thinkit's a bug on my part
is there a way to minimize these kind of errors?
Hi,
I call edittext.backspace() and it delete the character but then appends 5. Please verify if its any issue.
Regards,
Miten.
I didn't want to do a pull request because I only have an informal piece of code.
Here is a method to compare images returned by adbclient.takeSnapshot()
. It provides nearly the same functionality as MonkeyImage.sameAs()
. Instead of calling image1.sameAs(image2, 0.95)
, you call sameAs(image1, image2, 0.95)
. This new sameAs()
function could easily be made a method of AdbClient.
# Requires Image from PIL
# Which should have been imported by the call to takeSnapshot()
def percentSame(image1, image2):
# If the images differ in size, return 0% same.
size_x1, size_y1 = image1.size
size_x2, size_y2 = image2.size
if (size_x1 != size_x2 or
size_y1 != size_y2):
return 0
# Images are the same size
# Return the percent of pixels that are equal.
numPixelsSame = 0
numPixelsTotal = sizze_x1 * size_y1
image1Pixels = image1.load()
image2Pixels = image2.load()
# Loop over all pixels, comparing pixel in image1 to image2
for x in range(size_x1):
for y in range(size_y1):
if (image1Pixels[x, y] == image2Pixels[x, y]):
numPixelsSame += 1
return float(numPixelsSame) / float(numPixelsTotal)
def sameAs(image1, image2, percent=1.0):
percentSame = percentSame(image1, image2)
return (percentSame >= percent)
With the dump.py script in homepage, View tree cannot be printed.
Monkeyrunner cannot deal with encoding 'ms936'.
Here's the error message:
130717 14:16:51.702:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
130717 14:16:51.702:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "C:\repo\IntTestBox\dump.py", line 31, in
ViewClient(*ViewClient.connectToDeviceOrExit()).traverse(transform=ViewClient.TRAVERSE_CIT)
File "pyclasspath/com/dtmilano/android/viewclient.py", line 1733, in traverse
File "pyclasspath/com/dtmilano/android/viewclient.py", line 1751, in _ViewClient__traverse
LookupError: unknown encoding 'ms936'
Platform: Win7, 64bit, sdk-tools ver22.0.1
Every time vc.dump() is done on same screen, it increases the amount of items inside dump.
To reproduce
Expected: Dump contents stay the same
Actual: Items in dump have multiplied, e.g. 2 checkboxes become 4 etc.
Children of android.webkit.WebView are not enumerated. Is there a way I can click through a web page/browser interface in order to achieve the same goals as for the 'normal' UI? Dumping those views too would be enough, even if they have no correspondent class in the returned dump.
AndroidViewClient Version: 4.2.1
Device: Nexus 7 running 4.2.2
Steps to reproduce:
>>> import os
>>> import sys
>>> from com.dtmilano.android.viewclient import ViewClient
>>> device, serialno = ViewClient.connectToDeviceOrExit(verbose=False)
>>> device.shell('logcat -c')
>>> device.takeSnapshot()
>>> device.shell('logcat -d')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "com/dtmilano/android/adb/adbclient.py", line 224, in shell
self.__send('shell:%s' % cmd, checkok=True, reconnect=False)
File "com/dtmilano/android/adb/adbclient.py", line 125, in __send
self.__checkok()
File "com/dtmilano/android/adb/adbclient.py", line 160, in __checkok
raise RuntimeError("ERROR: %s %s" % (repr(recv), error))
RuntimeError: ERROR: ''
>>> Alarm clock
Please note that the above code block was typed (not copy-and-pasted), so it may contain typos. Ask for clarification if I've missed something.
This error was NOT reproduced with a simple
>>> device.shell('logcat -c')
>>> device.shell('logcat -d')
Only when a call to >>> device.takeSnapshot()
inbetween.
A call to >>> device.wake()
between the logcat clear and dispaly calls did not have an error.
I am using AndroidViewClient for these configurations:
Intel PC , with Android jellybean desktop version
Model number :Full android on PC
Android version: 4.1.2
Kernel version : 3.4.5
I am doing this in my monkeyrunner script -
vc = ViewClient(device)
vc.dump()
But the vc.dump() function hangs sometimes
I get this in the adb logcat -
W/WindowManager(13245): Could not send command dump with parameters
W/WindowManager(13245): java.net.SocketException: Socket is closed
W/WindowManager(13245): at java.net.PlainSocketImpl.checkNotClosed(PlainSocketImpl.java:134)
W/WindowManager(13245): at java.net.PlainSocketImpl.getOutputStream(PlainSocketImpl.java:249)
W/WindowManager(13245): at java.net.Socket.getOutputStream(Socket.java:385)
W/WindowManager(13245): at com.android.server.wm.WindowManagerService.viewServerWindowCommand(WindowManagerService.java:6156)
W/WindowManager(13245): at com.android.server.wm.ViewServer$ViewServerWorker.run(ViewServer.java:249)
W/WindowManager(13245): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
W/WindowManager(13245): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
W/WindowManager(13245): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
W/WindowManager(13245): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
W/WindowManager(13245): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
W/WindowManager(13245): at java.lang.Thread.run(Thread.java:856)
W/ViewServer(13245): An error occurred with the command: dump
What about adding support to touch() method in order to be able to touch at certain coordinates, specified in percentage? Setting them by default at "px = 50, py = 50" won't modify the current method's behaviour.
It would be useful to be able to choose which occurrence of a findViewById/findViewWithText/... we want to get.
For example if the word "application" is on a page twice we would do:
if bpp = 32
the mode is set to AGR. This in an invalid and not recognized mode.
There seems to be something wrong in the next line where the sorting is done. if sorted is removed, Then the mode becomes RGA
Hi,
I have been getting xml parsing error (like ExpatError) causing my app to crash. whats the solution ? I found http://code.google.com/p/android/issues/detail?id=35915 is that the reason ?
ERROR: Offending XML:
u'ERROR: null root node returned by UiTestAutomationBridge.\r\n'
I am using latest code AndroidViewClient-6cd170e65a8869fd9d5915a984342aa3b8937ce7
Regards,
Miten.
Hi Dtmilano,
I am not able to run Android View Client examples in Windows.
Please find the below error logs.
E:\android-sdk\tools>monkeyrunner browser-open-url.py
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "E:\android-sdk\tools\browser-open-url.py", line 40, in
vc = ViewClient(device)
TypeError: init() takes at least 3 arguments (2 given)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Throwable.(Throwable.java:181)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Exception.(Unknown Source)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.RuntimeException.(Unknown Source)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:46)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:43)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:61)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.TypeError(Py.java:195)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:275)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:385)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:380)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyInstance.init(PyInstance.java:120)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyClass.call(PyClass.java:194)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:397)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:401)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.f$0(E:\android-sdk\tools\browser-open-url.py:46)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.call_function(E:\android-sdk\tools\browser-open-url.py)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyCode.call(PyCode.java:18)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.runCode(Py.java:1197)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.builtin.execfile_flags(builtin.java:538)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
121110 16:23:40.314:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)
E:\android-sdk\tools>monkeyrunner click-button-by-text.py
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "E:\android-sdk\tools\click-button-by-text.py", line 31, in
vc = ViewClient(device)
TypeError: init() takes at least 3 arguments (2 given)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Throwable.(Throwable.java:181)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Exception.(Unknown Source)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.RuntimeException.(Unknown Source)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:46)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:43)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:61)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.TypeError(Py.java:195)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:275)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:385)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:380)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyInstance.init(PyInstance.java:120)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyClass.call(PyClass.java:194)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:397)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:401)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.f$0(E:\android-sdk\tools\click-button-by-text.py:44)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.call_function(E:\android-sdk\tools\click-button-by-text.py)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyCode.call(PyCode.java:18)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.runCode(Py.java:1197)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.builtin.execfile_flags(builtin.java:538)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
121110 16:34:56.735:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)
E:\android-sdk\tools>monkeyrunner dump.py
E:\AndroidViewClient\src\com\dtmilano\android\viewclient.py:890: UserWarning: Running on emulator but no serial number was specified then 'emulator-5554' is used
warnings.warn("Running on emulator but no serial number was specified then 'emulator-5554' is used")
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "E:\android-sdk\tools\dump.py", line 30, in
ViewClient(*ViewClient.connectToDeviceOrExit()).traverse(transform=ViewClient.TRAVERSE_CIT)
File "E:\AndroidViewClient\src\com\dtmilano\android\viewclient.py", line 747, in init
adb = ViewClient.obtainAdbPath()
File "E:\AndroidViewClient\src\com\dtmilano\android\viewclient.py", line 830, in _ViewClient__obtainAdbPath
possibleChoices = [ os.path.join(ANDROID_HOME, 'platform-tools', adb),
File "E:\android-sdk\tools\lib\jython.jar\Lib\os.py", line 898, in __getitem
KeyError: HOME
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Throwable.(Throwable.java:181)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Exception.(Unknown Source)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.RuntimeException.(Unknown Source)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:46)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:43)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.KeyError(Py.java:185)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.getitem(PyObject.java:661)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at os$py.getitem$60(E:\android-sdk\tools\lib\jython.jar\Lib\os.py:898)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at os$py.call_function(E:\android-sdk\tools\lib\jython.jar\Lib\os.py)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:146)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:327)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:322)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyInstance.invoke(PyInstance.java:206)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyInstance.instance___getitem__(PyInstance.java:633)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyInstance.getitem(PyInstance.java:628)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py._ViewClient__obtainAdbPath$47(E:\AndroidViewClient\src\com\dtmilano\android\viewclient.py:862)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py.call_function(E:\AndroidViewClient\src\com\dtmilano\android\viewclient.py)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:117)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:307)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py.init$45(E:\AndroidViewClient\src\com\dtmilano\android\viewclient.py:810)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py.call_function(E:\AndroidViewClient\src\com\dtmilano\android\viewclient.py)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:385)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:380)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyInstance.init(PyInstance.java:120)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyClass.call(PyClass.java:194)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject._callextra(PyObject.java:537)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.f$0(E:\android-sdk\tools\dump.py:30)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.call_function(E:\android-sdk\tools\dump.py)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyCode.call(PyCode.java:18)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.runCode(Py.java:1197)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.builtin.execfile_flags(builtin.java:538)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
121110 16:43:06.358:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)
My Windows PC enivronmenr variables Information
ANDROID_HOME=E:\android-sdk
ANDROID_VIEW_CLIENT_HOME=E:\AndroidViewClient
Path=%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
Could you please help me how to run the AndroidViewClient examples in windows PC ?
i'm trying to start one of the examples and i get an error
can you help me figure it out?
C:\Users\LEV>monkeyrunner C:\TEST\monkeyTest.py
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Scri
pt terminated due to an exception
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Trace
back (most recent call last):
File "C:\TEST\monkeyTest.py", line 26, in
device, serialno = ViewClient.connectToDeviceOrExit()
AttributeError: type object 'com.dtmilano.android.viewclient.ViewClient' has no
attribute 'connectToDeviceOrExit'
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.AttributeError(Py.java:145)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyType.noAttributeError(PyType.java:1513)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyObject.getattr(PyObject.java:931)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.pycode._pyx0.f$0(C:\TEST\monkeyTest.py:38)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.pycode._pyx0.call_function(C:\TEST\monkeyTest.py)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyTableCode.call(PyTableCode.java:165)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.PyCode.call(PyCode.java:18)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.runCode(Py.java:1197)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.builtin.execfile_flags(builtin.java:538)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
130606 19:49:42.833:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:18
9)
I verified this bug using the following script on the Temperature Converter (3500_10_source) from Packt:
device, serialno = ViewClient.connectToDeviceOrExit() MonkeyRunner.sleep(5) viewclient = ViewClient(device, serialno) viewclient.dump() MonkeyRunner.sleep(1) menuButton = viewclient.findViewWithContentDescriptionOrRaise('More options') menuButton.touch() MonkeyRunner.sleep(1) viewclient.dump() MonkeyRunner.sleep(1) prefButton = viewclient.findViewWithTextOrRaise('Preferences') print prefButton.getCenter() # (900, 323) prefButton.touch() MonkeyRunner.sleep(1)
What happens is that we get an X value that is ridiculous for the menu item. I'm trying to press the Preferences button, but the X value for the touch() command is 900 on a device with only 768 width. I think that the adjustment of adding the virtual window to the actual x is causing this problem.
AndroidViewClient 4.0.0
I get error when use 'forceviewserveruse' option:
File "./dump", line 134, in vc = ViewClient(*ViewClient.connectToDeviceOrExit(**kwargs1), **kwargs2) File "/opt/AndroidViewClient/src/com/dtmilano/android/viewclient.py", line 1219, in __init__ 'tcp:%d' % self.remotePort]) File "/usr/lib/python2.7/subprocess.py", line 537, in check_call retcode = call(*popenargs, **kwargs) File "/usr/lib/python2.7/subprocess.py", line 524, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.7/subprocess.py", line 711, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1308, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
Option is no longer supported? I need this option to use findViewById
Hi,
when used findViewWithText to find the following text "NÃO", function does not find the text, even if it exists. If I use it findViewByIdOrRaise of the following error:
viewclient.py, line 899, in str
str += a + "=" + self.map[a].__str() + " "
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2:ordinal not in range(128)
hi,when i input MonkeyRunner d:\mytest.py
i get the issues like this:
java.until.logging.ErrorManager:5
UnicodeEncodeError:'ascii' codec can't encode character in position 130-138 ordinal not in range(128)
Pose you can help me! Thanks
On my Nexus 7 (stock 4.3), anything that relies on getprop('display.height') or getprop('display.width') fails as those commands return nothing.
Running adb shell getprop on my Nexus 7 returns two properties that may be of use:
persist.sys.NV_DISPXRES (value 800)
persist.sys.NV_DISPYRES (value 1280)
I am not sure if this is a change in Android 4.3 properties, a Nexus 7 issue. Seems outside the scope of AndroidViewClient, other than it appears that AndroidViewClient assumes the height and width properties will exist.
Update:
I do not think that 'display.height' and 'display.width' are generic for the getprop command. If you look at the source for the monkey daemon, (http://androidxref.com/4.3_r2.1/xref/development/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkVars.java#86), you can see these values are discovered in some other way.
I am running AndroidViewClient (4.2.1) jar on Mac OSX (10.8.2)
Python 2.7.2
Java 1.7.0_17
I get following error.
$: java -jar androidviewclient-4.2.1.jar dump
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "/Users/kapil/dump", line 134, in
vc = ViewClient(_ViewClient.connectToDeviceOrExit(__kwargs1), *_kwargs2)
File "/Users/kapil/Playground/AndroidViewClient/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/viewclient.py", line 1376, in connectToDeviceOrExit
File "/Users/kapil/Playground/AndroidViewClient/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py", line 79, in init
File "/Users/kapil/Playground/AndroidViewClient/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py", line 191, in _AdbClient__setTransport
File "/Users/kapil/Playground/AndroidViewClient/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py", line 214, in getDevices
File "/Users/kapil/Playground/AndroidViewClient/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py", line 140, in _AdbClient__receive
NameError: global name 'bytearray' is not defined
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.NameError(Py.java:220)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFrame.getglobal(PyFrame.java:284)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.AdbClient__receive$13(/Users/kapil/Playground/AndroidViewClient/AndroidV
iewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py:148)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.call_function(/Users/kapil/Playground/AndroidViewClient/AndroidViewClient
/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:385)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:215)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.instancemethod___call_(PyMethod.java:221)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:206)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:381)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:385)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.getDevices$18(/Users/kapil/Playground/AndroidViewClient/AndroidViewClient
/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py:217)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.call_function(/Users/kapil/Playground/AndroidViewClient/AndroidViewClient
/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:385)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:215)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
30910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:206)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:381)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:385)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.AdbClient__setTransport$17(/Users/kapil/Playground/AndroidViewClient/And
roidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py:202)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.call_function(/Users/kapil/Playground/AndroidViewClient/AndroidViewClient
/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:385)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:215)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.instancemethod___call_(PyMethod.java:221)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:206)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:381)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:385)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.init$6(/Users/kapil/Playground/AndroidViewClient/AndroidViewClient/bi
n/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py:79)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.adb.adbclient$py.call_function(/Users/kapil/Playground/AndroidViewClient/AndroidViewClient
/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:191)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:385)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:380)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyInstance.init(PyInstance.java:120)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyClass.call(PyClass.java:194)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:397)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:401)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py.connectToDeviceOrExit$71(/Users/kapil/Playground/AndroidViewClient/AndroidVi
ewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/viewclient.py:1403)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.dtmilano.android.viewclient$py.call_function(/Users/kapil/Playground/AndroidViewClient/AndroidViewClient/bi
n/androidviewclient-4.2.1.jar/com/dtmilano/android/viewclient.py)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:370)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.function___call__(PyFunction.java:375)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyFunction.call(PyFunction.java:365)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject._callextra(PyObject.java:537)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.f$0(/Users/kapil/dump:136)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.call_function(/Users/kapil/dump)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyCode.call(PyCode.java:18)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.runCode(Py.java:1197)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.builtin.execfile_flags(builtin.java:538)
130910 20:24:46.241:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
Hi, I tried to run a simple test case with the following command, but it failed with incorrection version error. Would you please take a look at the problem?
jikk@ubuntu:/tmp/AndroidViewClient-4.2.1/AndroidViewClient/bin$ java -jar androidviewclient-4.2.1.jar dump
131007 10:03:47.617:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
131007 10:03:47.617:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "/home/jikk/dump", line 134, in
vc = ViewClient(_ViewClient.connectToDeviceOrExit(__kwargs1), *_kwargs2)
File "/tmp/AndroidViewClient-4.2.1/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/viewclient.py", line 1376, in connectToDeviceOrExit
File "/tmp/AndroidViewClient-4.2.1/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py", line 76, in init
File "/tmp/AndroidViewClient-4.2.1/AndroidViewClient/bin/androidviewclient-4.2.1.jar/com/dtmilano/android/adb/adbclient.py", line 181, in checkVersion
RuntimeError: ERROR: Incorrect version 0004001d
131007 10:03:47.617:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
131007 10:03:47.617:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Throwable.(Throwable.java:181)
131007 10:03:47.617:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Exception.(Exception.java:29)
Is it possible to implement something like startActivityOrExit?
When you try to start an activity that does not exist, the script fails silently.
Is there a way to capture an exception or stop running the script when the activity is not found?
Thanks!
When calling View.getCenter() (or any other coordinate method) on a View in a Dialog (or generically, "window" not filling the entire screen), the returned coordinates are incorrect.
The issue is easy to see by displaying the map of the first View (id/no_id/1) and noticing the X,Y bounds. Then call getXY() on that same View. The X bound will probably be 0 in both cases, but the Y value from getXY() will be double that from the bounds in the View's map. For instance, if the bounds shown in the map are (0, 50), then getXY() will return (0, 100).
To find the correct center of a View in a Dialog, use the following workaround:
# firstView has UniqueId id/no_id/1
# desiredView is the View we care about
(topX, topY) = firstView.getXY()
(X, Y) = desiredView.getCenter()
correctX = X - topX / 2
correctY = Y - topY / 2
In my case, I am running monkeyrunner scripts through another program, hence I will not be passing the serialno as a commandline parameter, instead I will be passing it as an arguement to function. If you consider adding it as a parameter to connectToDeviceOrExit() function, it would be great.
github completely reformatted by patch.
--- /tmp/8sTxDd_viewclient.py
+++ /home/durai/automation/AndroidViewClient/AndroidViewClient/src/com/dtmilano/android/viewclient.py
@@ -1015,7 +1015,7 @@
return serialno
@staticmethod
progname = os.path.basename(sys.argv[0])
# eat all the extra options the invoking script may have added
while len(sys.argv) > 1 and sys.argv[1][0] == '-':
sys.argv.pop(1)
serialno = sys.argv[1] if len(sys.argv) > 1 else \
os.environ['ANDROID_SERIAL'] if os.environ.has_key('ANDROID_SERIAL') \
else '.*'
if serialno is None:
while len(sys.argv) > 1 and sys.argv[1][0] == '-':
sys.argv.pop(1)
serialno = sys.argv[1] if len(sys.argv) > 1 else \
os.environ['ANDROID_SERIAL'] if os.environ.has_key('ANDROID_SERIAL') \
else '.*'
if verbose:
print 'Connecting to a device with serialno=%s with a timeout of %d secs...' % (serialno, timeout)
# Sometimes MonkeyRunner doesn't even timeout (i.e. two connections from same process), so let's
Hi,
i have take latest master branch and run it. It will give alarm not implemented on this platform error. I need to use monkeyrunner dump --force-view-server-use
Please tell me how to solve this problem? (I use Emulator-5554), Thanks.
E:\sdkr18\android-sdk-windows\tools>monkeyrunner dump.py
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] Script terminated due to an exception
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
]Traceback (most recent call last):
File "E:\sdkr18\android-sdk-windows\tools\dump.py", line 30, in
device, serialno = ViewClient.connectToDeviceOrExit()
File "C:\Documents and Settings\Administrator\AndroidViewClient\AndroidViewCli
ent\src\com\dtmilano\android\viewclient.py", line 783, in connectToDeviceOrExit
signal.alarm(timeout+5)
File "E:\sdkr18\android-sdk-windows\tools\lib\jython.jar\Lib\signal.py", line
222, in alarm
NotImplementedError: alarm not implemented on this platform
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at java.lang.Throwable.(Throwable.java:181)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at java.lang.Exception.(Exception.java:29)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at java.lang.RuntimeException.(RuntimeException.java:32)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyException.(PyException.java:46)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyException.doRaise(PyException.java:219)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.makeException(Py.java:1159)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.makeException(Py.java:1163)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.makeException(Py.java:1167)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at signal$py.alarm$14(E:\sdkr18\android-sdk-windows\tools\lib\jython.jar
\Lib\signal.py:239)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at signal$py.call_function(E:\sdkr18\android-sdk-windows\tools\lib\jytho
n.jar\Lib\signal.py)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:131)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.call(PyFunction.java:317)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.dtmilano.android.viewclient$py.connectToDeviceOrExit$47(C:\Docume
nts and Settings\Administrator\AndroidViewClient\AndroidViewClient\src\com\dtmil
ano\android\viewclient.py:798)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.dtmilano.android.viewclient$py.call_function(C:\Documents and Set
tings\Administrator\AndroidViewClient\AndroidViewClient\src\com\dtmilano\android
\viewclient.py)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:297)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyBaseCode.call(PyBaseCode.java:111)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyFunction.call(PyFunction.java:307)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.pycode._pyx0.f$0(E:\sdkr18\android-sdk-windows\tools\dump.
py:31)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.pycode._pyx0.call_function(E:\sdkr18\android-sdk-windows\t
ools\dump.py)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyTableCode.call(PyTableCode.java:165)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.PyCode.call(PyCode.java:18)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.Py.runCode(Py.java:1197)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.core.builtin.execfile_flags(builtin.java:538)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156
)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.
java:77)
121108 15:03:10.984:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter
.java:189)
With adbclient, the device.wake()
command presses the power button, toggling the sleep/wake state of the screen. If the screen is awake already and you issue device.wake()
the screen will go to sleep.
This is an issue because I often want to ensure that the screen is awake prior to taking a screenshot (otherwise, you get a blank screenshot). As is, I don't think there is a method to determine if the screen is awake.
I have two thoughts on this:
(1)
Perhaps look into sending the wake event like ChimpManager does (http://androidxref.com/4.3_r2.1/xref/tools/swt/chimpchat/src/main/java/com/android/chimpchat/ChimpManager.java#376). This approach ultimately writes "wake\n" to a socket connection to the monkey daemon on the device. Looking through AndroidViewClient's AdbClient script, does this talk to only ADB on the host (the PC the script runs on) or does AdbClient also talk to the device's monkey daemon directly? Talking to the monkey daemon directly may be valuable. I think I have some proof-of-concept code for this if you want it.
(2)
This method could use adb shell dumpsys power
and look at the mWakefulness
attribute. This may vary from device to device, but on my Nexus 7 it returns "Asleep" if the device is asleep and "Awake" when the screen is on already.
When I try to run the settings-display.py script in the examples folder, I get this error message:
gabriel@gabriel-pc:~/android/AndroidViewClient/examples$ monkeyrunner settings-display.py 192.168.42.1
settings-display.py: ERROR: Couldn't connect to 192.168.42.1: java.lang.NullPointerException
That's odd, because in my test scripts I use MonkeyRunner.waitForConnection(sys.argv[1]) and the device object is created.
If I comment the device, serialno = ViewClient.connectToDeviceOrExit() line, and use serialno = sys.argv[1] and device = MonkeyRunner.waitForConnection(serialno) and run the script again, I get the following error:
gabriel@gabriel-pc:~/android/AndroidViewClient/examples$ monkeyrunner settings-display.py 192.168.42.1
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "/home/gabriel/android/AndroidViewClient/examples/settings-display.py", line 44, in
device.wake()
at com.android.monkeyrunner.MonkeyDevice.wake(MonkeyDevice.java:357)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.lang.NullPointerException: java.lang.NullPointerException
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.fillInStackTrace(PyException.java:70)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Throwable.(Throwable.java:181)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.Exception.(Exception.java:29)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.RuntimeException.(RuntimeException.java:32)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:46)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyException.(PyException.java:43)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.JavaError(Py.java:455)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.JavaError(Py.java:448)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:177)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:355)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:215)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:221)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyMethod.call(PyMethod.java:206)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:381)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyObject.call(PyObject.java:385)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.f$0(/home/gabriel/android/AndroidViewClient/examples/settings-display.py:62)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.pycode._pyx0.call_function(/home/gabriel/android/AndroidViewClient/examples/settings-display.py)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyTableCode.call(PyTableCode.java:165)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyCode.call(PyCode.java:18)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.Py.runCode(Py.java:1197)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.builtin.execfile_flags(builtin.java:538)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:156)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:189)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Caused by: java.lang.NullPointerException
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.MonkeyDevice.wake(MonkeyDevice.java:357)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at java.lang.reflect.Method.invoke(Method.java:597)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:175)
120920 17:17:55.064:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] ... 16 more
I have put a device.wake() line before the startActivity line.
This behavior is very strange. I do not understand what's the problem. I use monkeyrunner for other test cases and it works.
On the x86 emulator, the settings-display.py script works.
Hi,
I am unable find API in AVC to do long press on screen. I have device running API 17. I read adbclient.py code and for API <=17 duration and count for drag are ignored.
I thought may be I could use drag keeping position same as workaround.
AVC AndroidViewClient-6cd170e65a8869fd9d5915a984342aa3b8937ce7
If I do cmd = 'input tap ' + str(center[0]) + ' ' + str(center [1])
it will simulate touch but do not know how to make it simulate long press touch.
is longClick possible with AVC ?
do I need to fallback to monkeyrunner based script for it as I see mentioned at places that following snippet should work for long press.
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import time
device = MonkeyRunner.waitForConnection()
device.touch(100, 100, MonkeyDevice.DOWN)
time.sleep(2); device.touch(100, 100, MonkeyDevice.UP)
so if I want to add above code in current non-monkeyrunner script can I do that ? I mean can I mix old monkeyrunner and current viewclient based codes ?
I am able to use subprocess.call as below as workaround:
call(['monkeyrunner.bat', 'd:\work\testing\avc\longpress.py'])
Regards,
miten.
HI
I am new to Monkey Runner....When I am Running ViewClient I am getting an Import Error called No Module named com...
plz help me to import the viewclient
I noticed that sometime the KeyEvents (like KEYCODE_MENU) are too fast so it don't work when you use two of them in a row. May be it would be a good idea too add a time.sleep(0.5) before and after all of them so that user don't have to write it each time?
I got it to work by changing the drag implementation to use
'input touchscreen swipe ....'
instead of
'input swipe ...'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.