ATX安装步骤及简单使用介绍
1.测试环境搭建
python[3.8]
python3.5及以下的版本后面执行连接手机connect的时候会报错,请安装3.6及以上版本。我装的版本是3.8的
1.1 安装atx
pip install atx
1.2 安装opencv
下面两种选择一种即可
镜像安装
pip install opencv-contrib-python -i https://pypi.mirrors.ustc.edu.cn/simple/
pip install opencv_python-3.2.0.7-cp35-cp35m-win32.whl
1.3 安装uiautomater
下面两种选择一种即可
pip install uiautomator
pip install --pre -U uiautomator2 # 安装最新版
1.4 抓取元素的weditor
pip install weditor
python -m uiautomator2 init 初始化插件
python -m weditor 打开浏览器抓取元素
2.代码简单试例:
# 连接设备,设备名可以通过adb命令拿到
cls.con = atx.connect('443993b8')
# 参数可以通过weditor拿到
cls.con.start_app('包名','MainActivity')
time.sleep(2)
# 截图操作
cls.con.screenshot(path)
3.其他
初学者可以通过
print(dir(cls.con))
打印出connect对象的所有属性和方法,遍于学习
以及ATX的api文档进行学习:https://github.com/NetEaseGame/ATX/blob/master/docs/API.md
例:安卓的对应的con的方法
['_AndroidDevice__display', '_DeviceMixin__keep_screen', '_DeviceMixin__last_screen', '_DeviceMixin__screensize', '__call__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_adb_client', '_adb_device', '_adb_shell_timeout', '_bounds', '_cal_scale', '_depth', '_host', '_listeners',
'_match_auto', '_mktemp', '_open_image_file', '_parse_xml_node', '_port', '_randid', '_resolution', '_take_screenshot', '_trigger_event', '_uiauto', 'adb_cmd', 'adb_device',
'adb_server_host', 'adb_server_port', 'adb_shell', 'add_listener', 'bounds', 'clear_text', 'click', 'click_exists', 'click_image', 'click_nowait', 'current_app', 'current_ime',
'current_package_name', 'delay', 'display', 'do_tap', 'drag', 'dump', 'dump_nodes', 'dump_view', 'exists', 'forward', 'free_screen', 'image_match_method',
'image_match_threshold', 'info', 'input_methods', 'is_app_alive', 'keep_screen', 'keyevent', 'last_screenshot', 'long_click', 'match', 'match_all', 'pattern_open', 'platform',
'press', 'properties', 'raw_cmd', 'region', 'region_screenshot', 'resolution', 'rotation', 'screen_rotation', 'screenshot', 'serial', 'sleep', 'source', 'start_app', 'stop_app', 'swipe',
'touch', 'touch_image', 'type', 'uiautomator', 'wait', 'wait_gone', 'wlan_ip']
本文地址:https://blog.csdn.net/dieorlife/article/details/107133898