zoukankan      html  css  js  c++  java
  • Python+Weditor

    1)下载、安装python

          1、进入python官网https://www.python.org/downloads/

          2、点击Download Python 3.7.3,即可下载python-3.7.3-amd64.exe

          3、下载完成后,点击即可安装python

    2)安装uiautomator2

          由于Python 3.7已经内置了pip,所以我们直接使用命令pip install --pre uiautomator2 即可安装uiautomator2:

          安装完成后,默认安装目录为:C:UsersAdministratorAppDataLocalProgramsPythonPython37Libsite-packagesuiautomator2

    3)使用USB连接设备,连接OK后运行命令python -m uiautomator2 init,该命令会自动安装本库所需要的设备端程序,也会在你的手机里安装两个软件一个可见一个不可见

         (有图标和没图标)

    4)安装可视化UI查看器  pip install --pre -U weditor

    5)打开CMD命令框,运行python -m weditor  ,该命令会在PC上打开浏览器,之后输入设备的ip或者序列号,点击Connect即可,映射测试机屏幕

         

    6)实例

    import uiautomator2 as u2
    import os
    import time 
    
    #d = u2.connect('172.16.0.7')
    d = u2.connect_usb('12345678')
    
    #进入应用列表
    d(resourceId="com.android.launcher3:id/all_apps_handle").click()
    time.sleep(5)
    
    # 启动AppWWW
    d(resourceId="com.android.launcher3:id/icon", text=u"骁龙相机").click()
    time.sleep(5)
    
    # 拍照
    d(resourceId="org.codeaurora.snapcam:id/shutter_button").click()
    time.sleep(5)
    
    # 切换摄像图
    d(resourceId="org.codeaurora.snapcam:id/front_back_switcher").click()
    time.sleep(5)
    
    #拍照
    d(resourceId="org.codeaurora.snapcam:id/shutter_button").click()
    time.sleep(5)
    
    
    #点击预览按钮
    d(resourceId="org.codeaurora.snapcam:id/preview_thumb").click()
    
    time.sleep(5)
    
    #按返回键
    for i in range(2):
        os.system("adb shell input keyevent 4")
        time.sleep(3)

         

        

       

  • 相关阅读:
    Kappa Architecture: A Different Way to Process Data
    Lambda architecture and Kappa architecture
    Questioning the lambda architecure
    Lambda Architecture: Achieving Velocity and Volume with Big Data
    beego 参数配置
    hadoop 3.1.1 安装
    Idea 切换git账号
    IntelliJ IDEA 开发git多模块项目
    打印1到1亿的平方
    IDEA 逆向工程
  • 原文地址:https://www.cnblogs.com/xmmc/p/10827495.html
Copyright © 2011-2022 走看看