求助!利用monkey命令去模拟滑动屏幕动作
#向右滑动
def scrollrightFling():
device.touch(888,600,MonkeyDevice.DOWN)
device.touch(200,600,MonkeyDevice.MOVE)
device.touch(200,600,MonkeyDevice.UP)
print "Fling right"
def fling1():
for i in range(2):
scrollrightFling()
image=device.takeSnapshot()
image.writeToFile("E:\Monkey\yunimage\youhua"+str(i)+".png","png")
附模拟滑动屏幕的代码,求助,APP可以成功完成“向右滑动”,但是向左滑动没有实现,可是可以成功打印出“Fling left”,也没有报错,这是因为什么呀?{:4_100:} #!/usr/bin/python
#coding=utf-8
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
import time
#连接设备
device=MonkeyRunner.waitForConnection(3)
#启动应用
device.startActivity("com.yunapp/.MainActivity")
MonkeyRunner.sleep(3)
#向右滑动
def scrollrightFling():
device.touch(888,600,MonkeyDevice.DOWN)
device.touch(200,600,MonkeyDevice.MOVE)
device.touch(200,600,MonkeyDevice.UP)
print "Fling right"
def fling1():
for i in range(2):
scrollrightFling()
image=device.takeSnapshot()
image.writeToFile("E:\Monkey\yunimage\youhua"+str(i)+".png","png")
#向左滑动
def scrollleftFling():
device.touch(155,800,MonkeyDevice.DOWN)
device.touch(988,800,MonkeyDevice.MOVE)
device.touch(988,800,MonkeyDevice.UP)
print "Fling left"
def fling2():
for i in range(2):
scrollleftFling()
image=device.takeSnapshot()
image.writeToFile("E:\Monkey\yunimage\zuohua"+str(i)+".png","png")
fling2()
time.sleep(2)
fling1()
刚刚看代码只是一部分,现在附上全部代码 感觉没问题
坐标是在屏幕内吧 jingzizx 发表于 2017-7-12 08:45
感觉没问题
坐标是在屏幕内吧
嗯嗯,坐标是在屏幕内,把“向右滑动”的坐标,反过来放到“向左滑动”里面,也是没有反应,感觉很奇怪
页:
[1]