Device press/touch with monkeyrunner on DroidBox don't work

我的未来我决定 提交于 2019-12-13 00:36:35

问题


I'm using a monkeyrunner script that works over DroidBox23, it is the script that cames by default in the DroidBox program, in the folder scripts/, but i modificated by this way:

    import re
    import sys
    import os
    import time

    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

    device = MonkeyRunner.waitForConnection()
    device.installPackage(sys.argv[1])
    package = sys.argv[2]
    activity = sys.argv[3]

    # sets the name of the component to start
    runComponent = package + '/' + activity
    print "Running: " + runComponent
    # Runs the component
    device.startActivity(component=runComponent)

    time.sleep(5)
    # Takes a screenshot
    print "Taking snapshot"
    result = device.takeSnapshot()
    # Writes the screenshot to a file
    result.writeToFile('shot1.png','png')
    print 'pulsamos'
    device.press("DPAD_UP", 'DOWN_AND_UP')
    print 'pulsado'
    device.touch(60,350, 'DOWN_AND_UP')

When it executes device.press() or device.touch(), these functions don't work:

    130509 17:23:38.641:S [main] [com.android.chimpchat.adb.AdbChimpDevice] Error sending touch event: 60 350 DOWN_AND_UP
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Broken pipe
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWrite0(Native Method)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.socketWrite(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at java.net.SocketOutputStream.write(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
130509 17:46:42.657:S [main] [com.android.chimpchat.adb.AdbChimpDevice] at sun.nio.cs.StreamEncoder.flush(Unknown Source)

Thanks for your help.

来源:https://stackoverflow.com/questions/16466013/device-press-touch-with-monkeyrunner-on-droidbox-dont-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!