|
本帖最后由 dksg8782 于 2011-7-14 08:56 编辑
#############示例代码#############
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
def tapButton(Number):
import random
for i in range(0,Number):
keyValue = random.randint(1,20)
if keyValue == 1:
device.touch(200,265)#Tap "Clear" button;
elif keyValue == 2:
device.drag((200,265),(200,265),1.5,10)#Long touch "Clear" button;
elif keyValue == 3:
device.touch(465,275)#Tap "Delete" button;
elif keyValue == 4:
device.drag((465,275),(465,275),1.5,10)#Long touch "Delete" button;
elif keyValue == 5:
device.touch(70,430)#Tap "7" button;
elif keyValue == 6:
device.touch(220,430)#Tap "8" button;
elif keyValue == 7:
device.touch(340,430)#Tap "9" button;
elif keyValue == 8:
device.touch(470,430)#Tap "division" button;
elif keyValue == 9:
device.touch(70,580)#Tap "4" button;
elif keyValue == 10:
device.touch(220,580)#Tap "5" button;
elif keyValue == 11:
device.touch(340,580)#Tap "6" button;
elif keyValue == 12:
device.touch(470,580)#Tap "x" button;
elif keyValue == 13:
device.touch(70,730)#Tap "1" button;
elif keyValue == 14:
device.touch(220,730)#Tap "2" button;
elif keyValue == 15:
device.touch(340,730)#Tap "3" button;
elif keyValue == 16:
device.touch(470,730)#Tap "-" button;
elif keyValue == 17:
device.touch(70,875)#Tap "." button;
elif keyValue == 18:
device.touch(220,875)#Tap "0" button;
elif keyValue == 19:
device.touch(340,875)#Tap "=" button;
elif keyValue == 20:
device.touch(470,875)#Tap "+" button;
else:
pass
#MonkeyRunner.sleep(0.2)
tapButton(10000) |
|