zoukankan      html  css  js  c++  java
  • 史上最全的MonkeyRunner自动化测试从入门到精通(1)

    原文地址https://zhuanlan.zhihu.com/p/26043620

    MonkeyRunner使用

    #-*- coding:utf-8 –*-
    from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
    #连接设备
    device=MonkeyRunner.waitForConnection(3,"172.10.10.124:5555")
    #启动App
    device.startActivity("包名/类名")
    #暂停两秒
    MonkeyRunner.sleep(2)
    #点击搜索框
    device.touch(100,100,"DOWN_AND_UP")
    #输入查询词
    device.type('test')
    #点击回车键
    device.press('KEYCODE_ENTER','DOWN_AND_UP')
    #点击搜索按钮
    device.touch(400,100,"DOWN_AND_UP")
    #截图
    image=device.takeSnapshot()
    image.writeToFile('./test.png','png')
    device.touch(300,100,"DOWN_AND_UP")
    #弹出框
    MonkeyRunner.alert('test over','This is title','OK')
    
    备注:
    1坐标值可通过 sdk自带的uiautomatorviewer获取
    2运行方式
     在tool目录下执行monkeyrunner file.py
  • 相关阅读:
    第9天 图片整合
    第六天 元素类型
    第五天 文本溢出
    第四天 盒子模型
    第三天 css核心属性
    第二天 css基础 ,部分选择符
    第一天 HTML基础
    *Move Zeroes
    Word Pattern
    ReentrantLock
  • 原文地址:https://www.cnblogs.com/111testing/p/8853432.html
Copyright © 2011-2022 走看看