Android MonkeyRunner occasionally throws exceptions

I run automatic testing using an Android emulator running an application with a Monkey script written in Python. The script copies files to the emulator, presses buttons in the application, and reacts depending on the actions that the software launches while it is running. The script is supposed to run the loop several thousand times, so I have this in the loop to run the adb tool to copy files, run actions and see how the software responds by calling the getProperty method on the device with the parameter "am.current.comp. class ". So here is a very simplified version of my script:

for target in targets:
    androidSDK.copyFile(emulatorName, target, '/mnt/sdcard')

    # Runs the component
    device.startActivity(component='com.myPackage/com.myPackage.myactivity')

    while 1:
        if device.getProperty('am.current.comp.class') == 'com.myPackage.anotheractivity':
            time.sleep(1) # to allow the scree to display the new activity before I click on it
            device.touch(100, 100, 'DOWN_AND_UP')
            # Log the result of the operation somewhere
            break

        time.sleep(0.1)

(androidSDK - , , adb).

, script , ( )

[com.android.chimpchat.adb.AdbChimpDevice]com.android.ddmlib.ShellCommandUnresponsiveException

[com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: am.current.comp.class
[com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Software caused connectionabort: socket write error

, - ( adb kill-server).

, , , Java (Monkey Jython), , Python script. script , (, , , MonkeyRunner.waitForConnection ?).

?

,

. , , , Jython script Java , - :

from java.net import SocketException

...

try:
    ...

except(SocketException):
    ...
+5
2

Jython script Java :

from java.net import SocketException

...

try:
    ...

except(SocketException):
    ...

( OP, )

0

: device.shell('exit') #

0

All Articles