出于某种原因,无论我做什么,我都不能使用AndroidViewClient向我的外部安卓设备发出“拖动”命令。这是我的代码:
import sys
import os
import time
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.adb.adbclient import AdbClient
from com.dtmilano.android.viewclient import ViewClient, View
print 'Connecting to device...'
device, serialno = ViewClient.connectToDeviceOrExit()
time.sleep(.5)
AdbClient(serialno='.*').drag((500,1000),(500,100), 1, 10)我也试过
device.drag((500,1000),(500,100), 1, 10)也不起作用。(顺便说一句,device.drag()与AdbClient.drag()有什么不同?)
另外,我不会从上面得到任何错误。一切都在运行,没有发现任何错误。它只是不拖动屏幕。
然而,触摸事件和键盘事件是有效的:
device.touch(400,200, 'DOWN_AND_UP')注意:我的AndroidViewCLient版本是7.0.2。我的android设备是Jellybean 4.1
编辑:我的android设备的输出:
C:\Users\Me>adb shell input
usage: input ...
input text <string>
input keyevent <key code number or name>
input tap <x> <y>
input swipe <x1> <y1> <x2> <y2>发布于 2014-06-06 19:54:18
我发现了问题。当AdbClient获得API级别(版本)时,它没有转换为int,所以AdbClient.drag()中的比较失败,因为它是一个字符串,并且错误的命令被发送到API 16。
__send(shell:input touchscreen swipe 500 400 100 400 1, checkok=True, reconnect=False)而不是
__send(shell:input swipe 500 400 100 400, checkok=True, reconnect=False)它将固定在AVC 7.0.4中。
https://stackoverflow.com/questions/23958646
复制相似问题