Skip to content

Instantly share code, notes, and snippets.

@Tolsi
Forked from sjp38/gist:6202539
Created February 4, 2018 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tolsi/d8b06b37350f203618a1a7b07f07ea42 to your computer and use it in GitHub Desktop.
Save Tolsi/d8b06b37350f203618a1a7b07f07ea42 to your computer and use it in GitHub Desktop.
Sample code for monkeyrunner's MOVE usage
#!/usr/bin/env monkeyrunner
import time
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
# Touch down screen
device.touch(100, 500, MonkeyDevice.DOWN)
# Move from 100, 500 to 300, 500
for i in range(1, 11):
device.touch(100 + 20 * i, 500, MonkeyDevice.MOVE)
print "move ", 100 + 20 * i, 500
time.sleep(0.1)
# Move from (300, 500 to 200, 500)
for i in range(1, 11):
device.touch(300, 500 - 10 * i, MonkeyDevice.MOVE)
print "move ", 300, 500 - 10 * i
time.sleep(0.1)
# Remove finger from screen
device.touch(300, 400, MonkeyDevice.UP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment