????MonkeyRunner????????????????????????????????????????????????????????????????????????????????????????app??????????????????Rom???????????????app?????????monkeyrunner???????????????????MonkeyRunner???????????????????????????????monkeyrecody.py??monkeyplayback.py??????????????????????????????????????google??????????????
???????????????????????MonkeyRunner???????????????????????????????????????Щ????????????????дmonkeyrunner???????г??????????????????????????????????·?????????????????????????ò??裬???????????????????????????????????????????????????ж???????????????log???????????????????????λ??????

 

????#!/usr/bin/env monkeyrunner# encoding=utf-8  #????python???????time????sys??飬????ж??????????import timeimport sys#MonkeyRunner?????????apifrom com.android.monkeyrunner import MonkeyRunner ??MonkeyDevice ??MonkeyImage#??????????????????????now=time.strftime("%Y-%m-%d-%H-%M-%S")#????????????????λ?ú???log??λ??path='D:\picture\'logpath="D:\log\"#python?л????????е??????????name=sys.argv[0].split("\")filename=name[len(name)-1]"""

????????????????????????????????????????python???????

 

print(name)
print(filename)
"""#??????log???log=open(logpath+filename[0:-3]+"-log"+now+".txt"??'w')#?????豸??????????????????????(???????????????λ)???豸?????к??device=MonkeyRunner.waitForConnection(5??'b4726a2d')#?????????apk????????apk?????λ??????python??????????????????????????.decode('utf-8')??????????device.installPackage ('D:\apk\??????.apk'.decode('utf-8'))#??????????????log?????log.write("???apk…… ")#???2??MonkeyRunner.sleep(2)#???app??????????app?????/????device.startActivity(component='com.smartisan.notes/.NotesActivity')MonkeyRunner.sleep(2)#??????????log.write("???app…… ")#???result = device.takeSnapshot()#?????? result.writeToFile(path+"?????".decode('utf-8')+now+'.png'??'png')#??????????λ??????device.touch(111??155??'DOWN_AND_UP')MonkeyRunner.sleep(2)#????smartisan????device.type("smartisan")#???result1=device.takeSnapshot()#??????result1.writeToFile(path+"????????".decode('utf-8')+'.png'??'png')#?????????????λ???????????????????????????????????????????????????????device.drag((232??235)??(216??472)??3??2)MonkeyRunner.sleep(3)#???result2=device.takeSnapshot()#??????result2.writeToFile(path+"??????".decode('utf-8')+now+".png"??'png')#???????????????device.drag((109??360)??(322??360))MonkeyRunner.sleep(3)#???result3=device.takeSnapshot()#??????result3.writeToFile(path+"????????".decode('utf-8')+now+".png"??'png')#?????????????λ??device.touch(182??583??'DOWN_AND_UP')MonkeyRunner.sleep(5)#????????λ??device.touch(324??73??'DOWN_AND_UP')MonkeyRunner.sleep(5)#????????????????λ??device.touch(227??789??'DOWN_AND_UP')MonkeyRunner.sleep(5)#?????????????λ??device.touch(228??791??'DOWN_AND_UP')MonkeyRunner.sleep(5)#???result4=device.takeSnapshot()#??????result4.writeToFile(path+"??????????".decode("utf-8")+now+'.png'??'png')#??????????λ??device.touch(426??81??'DOWN_AND_UP')MonkeyRunner.sleep(3)#???result5=device.takeSnapshot()#??????result5.writeToFile(path+"??????????".decode("utf-8")+now+'.png'??'png')#??????????????????????λ??????????????????device.touch(196??311??'DOWN_AND_UP')MonkeyRunner.sleep(3)device.type("powermo@126.com")MonkeyRunner.sleep(3)device.touch(168??378??'DOWN_AND_UP')MonkeyRunner.sleep(3)device.type("powermo1234")MonkeyRunner.sleep(3)#??????device.touch(237??449??'DOWN_AND_UP')MonkeyRunner.sleep(3)#???result6=device.takeSnapshot()#??????result6.writeToFile(path+"??????".decode("utf-8")+now+'.png'??'png')#???濪????????????ж????#?????????????????????????????????resultTrue=MonkeyRunner.loadImageFromFile('D:\picture2\shottrue.png')log.write("?????????…… ")#?ж??????????????90%if(result.sameAs(resultTrue??0.9)):
#???????д???????
print("????????????")
#????????log???
log.write("????????????…… ")else:
#??????????????
print("?????????????")
log.write("?????????????…… ")#?????????????漲???????????result1True=MonkeyRunner.loadImageFromFile('D:\picture2\shottrue1.png')#?ж??????????????90%if(result1.sameAs(result1True??0.9)):
print("?????????????")
log.write("?????????????…… ")else:
print("??????????????")
log.write("??????????????…… ")#?????????????result2True=MonkeyRunner.loadImageFromFile('D:\picture2\shottrue2.png')##?ж??????????????80%if(result2.sameAs(result2True??0.8)):
print("???????????")
log.write("???????????…… ")else:
print("??????????????")
log.write("????????????…… ")#?????????????ж???????????????漲????result3True=MonkeyRunner.loadImageFromFile('D:\picture2\shottrue3.png')##?ж??????????????80%if(result3.sameAs(result3True??0.8)):
print("?????????????")
log.write("?????????????…… ")else:
print("??????????????")
log.write("??????????????…… ")#???????????result4True=MonkeyRunner.loadImageFromFile('D:\picture2\shottrue4.png')if(result4.sameAs(result4True??0.8)):
print("??????????????")
log.write("??????????????…… ")else:
print("???????????????")
log.write("???????????????…… ")result5True=MonkeyRunner.loadImageFromFile('D:\picture2\shottrue5.png')if(result5.sameAs(result5True??0.8)):
print("?????????????????")
log.write("?????????????????…… ")else:
print("??????????????????")
log.write("??????????????????…… ")result6True=MonkeyRunner.loadImageFromFile('D:\picture2\shottrue6.png')if(result6.sameAs(result6True??0.8)):
print("?????????????")
log.write("?????????????…… ")else:
print("??????????????")
log.write("??????????????…… ")