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
    

      

  • 相关阅读:
    安装hp驱动
    原来这才是真的卑躬屈膝
    vim好文集锦
    解决python交互时无法使用回格键
    难道父母比希望你快乐吗?
    从C 语言用户角度理解 Linux 的库
    树梅派屏幕旋转方法
    如此瘸了
    一首难忘的歌
    将安卓手机屏幕投射到 Linux
  • 原文地址:https://www.cnblogs.com/paulwinflo/p/5207252.html
Copyright © 2011-2022 走看看