zoukankan      html  css  js  c++  java
  • MonkeyRunner_真机_运行脚本(二)

     1 # -*- coding: UTF-8 -*-  
     2 #手机分辨率为1080*1920
     3 import sys
     4 from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
     5 
     6 def install(d):
     7     MonkeyRunner.sleep(3)
     8     d.removePackage('com.xxx.phone')
     9     print "uninstall success!!"
    10     MonkeyRunner.sleep(2)
    11     d.installPackage('d:mkxxxphone.apk')
    12     print "install success!!"
    13     MonkeyRunner.sleep(2)
    14 
    15     d.wake()
    16     d.touch(800,1900,'DOWN_AND_UP')  
    17     MonkeyRunner.sleep(2)
    18     d.startActivity(component="com.xxx.phone/com.xxx.phone.activity.WelcomeActivity") 
    19     MonkeyRunner.sleep(5)
    20     d.wake()
    21     d.drag((800,600),(400,600),0.1,10) 
    22     d.wake()
    23     MonkeyRunner.sleep(2)
    24     d.drag((800,600),(300,600),0.1,10) 
    25     MonkeyRunner.sleep(2)    
    26     d.touch(530,1600,'DOWN_AND_UP') 
    27     MonkeyRunner.sleep(3)
    28     d.touch(533,1007,'DOWN_AND_UP') 
    29     MonkeyRunner.sleep(2)    
    30     d.touch(533,1800,'DOWN_AND_UP') 
    31 
    32 def main():
    33     print "Start"
    34     device=MonkeyRunner.waitForConnection()
    35     if not device:
    36         print "Couldn't connect the device"
    37         sys.exit()
    38     print "Conneted device"
    39     install(device)
    40     
    41     
    42 if __name__ == '__main__':
    43     main()

    1.因为在Notepad默认编码为Ascll,所以在首行加入编码注释(必须放在第一行或者第二行),# -*- coding:utf-8 -*- 

    2.因为是按坐标执行,代码只支持对应的分辨率,手机分辨率可在设置中查看或者画图软件中查看最大坐标值,#手机分辨率为1080*1920

    3. 每个用例可以封装为一个函数 def

  • 相关阅读:
    SQLyog连接MySQL8.0报2058错误的完美解决方法
    WPF之Binding深入探讨未参考
    C# SQLite 创建数据库的方法增删查改语法和命令
    winform实现INotifyPropertyChanged
    排序算法
    GitHub代码上传
    SQLyog
    Jenkins 部署 .NET MVC 项目
    Visual Studio 2019 代码规范
    C# SqlHelper类
  • 原文地址:https://www.cnblogs.com/happy-xiaoxiao/p/8268460.html
Copyright © 2011-2022 走看看