airtest本地连接和远程连接

时间:2022-07-26
本文章向大家介绍airtest本地连接和远程连接,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一.本地连接

# -*- coding: utf-8 -*-#
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
from airtest.core.api import *
class_name = '059b670d0c634127'
connect_device(f"Android:///{class_name}?cap_method=JAVACAP&&ori_method=ADBORI&&touch_method=ADBTOUCH")
#其中cap_method=JAVACAP&&ori_method=ADBORI&&touch_method=ADBTOUCH 对应你在airtest编辑器上连接时候的勾选
dev=set_current(class_name) 
#多机操作时候需要加,切换到你想要操作的机子上
poco = AndroidUiautomationPoco(device=dev,use_airtest_input=True, screenshot_each_action=False)

二.远程连接

手机建立服务
adb tcpip 5555
查看手机ip
adb shell ifconfig wlan0  #其中 inet addr:xxxxx就是了
进行连接
adb connect 手机ip:5555