zoukankan      html  css  js  c++  java
  • 【monkeyrunner】monkeyrunner 实例

    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:howdoTestmarketLogoTestpackages"
    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:howdoTestmarketLogoTestsnapshots\'+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:howdoTestmarketLogoTestsnapshots\'+packageFile+'snapshotIsnew.png','png')
                mr.sleep(1)
                device.touch(184,555,"DOWN_AND_UP")
                mr.sleep(1)
                snapshotVersion=device.takeSnapshot()
                snapshotVersion.writeToFile('E:howdoTestmarketLogoTestsnapshots\'+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
    

      

  • 相关阅读:
    Cookies 和 Session的区别
    List接口、Set接口和Map接口
    Java NIO:IO与NIO的区别
    NIO与传统IO的区别
    Java中堆内存和栈内存详解
    Java序列化与反序列化
    maven搭建
    深入研究java.lang.ThreadLocal类
    SQL 优化经验总结34条
    数据库事务的四大特性以及事务的隔离级别
  • 原文地址:https://www.cnblogs.com/paulwinflo/p/5207252.html
Copyright © 2011-2022 走看看