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
    

      

  • 相关阅读:
    flex设置成1和auto有什么区别
    在SUBLIME TEXT中安装SUBLIMELINTER进行JS&CSS代码校验
    gulp教程之gulp-less
    sublime注释插件与javascript注释规范
    移动端尺寸基础知识
    webpack入门教程
    IO中同步、异步与阻塞、非阻塞的区别
    Node.js的线程和进程
    Cocos2d-x 3.0中 物理碰撞检測中onContactBegin回调函数不响应问题
    hdu 1789 Doing Homework again 贪心
  • 原文地址:https://www.cnblogs.com/paulwinflo/p/5207252.html
Copyright © 2011-2022 走看看