zoukankan      html  css  js  c++  java
  • uiautomator2学习【一】

    一、uiautomator2简介

    uiautomator2 是一个可以使用Python对Android设备进行UI自动化的库。

    其底层基于Google uiautomator,Google提供的uiautomator库可以获取屏幕上任意一个APP的任意一个控件属性,并对其进行任意操作。

    二、环境准备

    • pip install uiautomator2

    Windows下使用pip安装包的时候出现如下问题:

    “WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available”

    解决办法:

    在环境变量Path中加入anaconda3的如下路径:

    D:ProgramDataAnaconda3condabin
    D:ProgramDataAnaconda3Scripts
    D:ProgramDataAnaconda3Libraryin
    D:ProgramDataAnaconda3

    • python

    Window10系统在命令行中输入python会跳转到商店问题解决方法:

    where python命令出现两个地址:

    一个是Python的,一个是应用商店的地址,在Win10菜单搜索【管理应用执行别名】关闭最下面的两个按钮:

    再进入cmd输入where python 就只有一个地址了:

     

    • 一个安卓系统设备或者一个模拟器

     需要将设备调至开发者模式:

    【系统应用】-【设置】-【关于平板电脑】-【版本号】连续单机5次。

    • ADB下载

    adb devices

    查看连接设备序列号及状态:

     

    adb shell wm size

    查看屏幕分辨率:

    adb get-state

    查看当前连接设备的状态:

     adb connect ip:端口号

    连接本机的模拟器只需要修改所安装的模拟器端口,雷电模拟器端口号是5555:

    截图并拉取至指定文件夹:

    通过adb命令截图 :adb shell screencap -p /sdcard/01.png

    拉取到电脑:adb pull <设备里的文件路径> [电脑上的目录]

    使用adb install 【apk路径】安装程序:

    使用adb shell input keyevent 25:减小音量

    使用adb shell input keyevent 24:增加音量

    使用adb shell input keyevent 164:静音

    多媒体暂停/播放/下一首/上一首:

    adb shell input keyevent KEYCODE_MEDIA_STOP

    adb shell input keyevent KEYCODE_MEDIA_PLAY

    adb shell input keyevent KEYCODE_MEDIA_NEXT

    adb shell input keyevent KEYCODE_MEDIA_PREVIOUS

    adb shell input keyevent 3:回到Home

    adb shell input keyevent 4:返回键

    KeyCode大全:https://blog.csdn.net/h_bpdwn/article/details/91425599

  • 相关阅读:
    jQuery事件
    jQuery选择器
    jQuery对象和语法
    jQuery简介
    残差的正态性检验——概率图和QQ-plot图
    https://oldpan.me/深度学习博客
    深度学习的内存消耗在哪里?
    图片缩放
    随机梯度下降批尺寸的影响
    利用PIL.ImageOps.invert实现二值图像黑白反转
  • 原文地址:https://www.cnblogs.com/direwolf22/p/15236283.html
Copyright © 2011-2022 走看看