装置按/与monkeyrunner上DroidBox碰不工作(Device press/touch

2019-10-18 02:47发布

我使用的是monkeyrunner脚本作品在DroidBox23,它是默认卡梅斯在DroidBox程序,在文件夹脚本/剧本,但我通过这种方式改性壳聚糖:

    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')

当执行device.press()或device.touch(),这些功能不起作用:

    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)

谢谢你的帮助。

文章来源: Device press/touch with monkeyrunner on DroidBox don't work