import time
import os
import re
from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner import MonkeyDevice as md
from com.android.monkeyrunner import MonkeyImage as mi regrex=r"(.*)\.apk"
dir="E:\howdoTest\marketLogoTest\packages"
activity="com.howdo.commonschool/com.howdo.commonschool.activities.WelcomeActivity"
device=mr.waitForConnection()
if os.path.exists(dir) and os.path.isdir(dir) :
for packageFile in os.listdir(dir):
if re.match(regrex, packageFile):
packageFilePath = os.path.join(dir,packageFile)
device.installPackage(packageFilePath)
time.sleep(2)
print "APK finish setup...."
time.sleep(1)
print "Start testing...."
device.startActivity(component=activity)
mr.sleep(1)
snapshotLogo=device.takeSnapshot()
#snapshotLogoName="e:\\"+packageFile+"snapshotLogo.png"
snapshotLogo.writeToFile('E:\howdoTest\marketLogoTest\snapshots\\'+packageFile+'snapshotLogo.png','png')
mr.sleep(10)
device.touch(195,1174,"DOWN_AND_UP")
mr.sleep(1)
device.type("*****")
mr.sleep(1)
device.touch(134,395,"DOWN_AND_UP")
mr.sleep(1)
device.type("*****")
mr.sleep(1)
device.touch(348,600,"DOWN_AND_UP")
mr.sleep(5)
device.touch(51,107,"DOWN_AND_UP")
mr.sleep(2)
device.touch(158,805,"DOWN_AND_UP")
mr.sleep(2)
device.touch(195,335,"DOWN_AND_UP")
time.sleep(1)
snapshotIsnew=device.takeSnapshot()
snapshotIsnew.writeToFile('E:\howdoTest\marketLogoTest\snapshots\\'+packageFile+'snapshotIsnew.png','png')
mr.sleep(1)
device.touch(184,555,"DOWN_AND_UP")
mr.sleep(1)
snapshotVersion=device.takeSnapshot()
snapshotVersion.writeToFile('E:\howdoTest\marketLogoTest\snapshots\\'+packageFile+'snapshotVersion.png','png')
time.sleep(1)
print "Finish testing..."
device.removePackage("com.howdo.commonschool")
time.sleep(2)
print packageFile+" finish unsetup...." else:
print 'path %s is not existed or is not a directory' %dir

  

05-11 11:16