How to use the airtest.core.android.adb.ADB function in airtest

To help you get started, we’ve selected a few airtest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buffaloleo143 / airtest_runner / mywindowdlg.py View on Github external
def ConnectRemoteADB(self):
		sText = self.TextAddr.text()
		sCmd = sText.split()[-2]
		sAddr = sText.split()[-1]
		if sCmd == 'connect':
			ADB(serialno=sAddr)
		elif sCmd == 'disconnect':
			ADB(serialno=sAddr).disconnect()
		else:
			QtWidgets.QMessageBox.information(self, "提示", self.tr("请输入正确指令!(connect or disconnect)"))
		self.RefreshADB()
github AirtestProject / Airtest / tests / test_adb.py View on Github external
def setUpClass(cls):
        devices = ADB().devices(state="device")
        if not devices:
            raise RuntimeError("At lease one adb device required")
        cls.adb = ADB(devices[0][0])
github buffaloleo143 / airtest_runner / utils.py View on Github external
def GetValidDevices():
	"""获取本地连接的设备号列表"""
	lData = ADB().devices('device')
	lPositiveDevices = [item[0] for item in lData]
	return lPositiveDevices
github AirtestProject / Airtest / airtest / core / android / android.py View on Github external
def __init__(self, serialno=None, host=None,
                 cap_method=CAP_METHOD.MINICAP_STREAM,
                 touch_method=TOUCH_METHOD.MINITOUCH,
                 ime_method=IME_METHOD.YOSEMITEIME,
                 ori_method=ORI_METHOD.MINICAP,
                 ):
        super(Android, self).__init__()
        self.serialno = serialno or self.get_default_device()
        self.cap_method = cap_method.upper()
        self.touch_method = touch_method.upper()
        self.ime_method = ime_method.upper()
        self.ori_method = ori_method.upper()
        # init adb
        self.adb = ADB(self.serialno, server_addr=host)
        self.adb.wait_for_device()
        self.sdk_version = self.adb.sdk_version
        self._display_info = {}
        self._current_orientation = None
        # init components
        self.rotation_watcher = RotationWatcher(self.adb)
        self.minicap = Minicap(self.adb, ori_function=self.get_display_info)
        self.javacap = Javacap(self.adb)
        self.minitouch = Minitouch(self.adb, ori_function=self.get_display_info)
        self.yosemite_ime = YosemiteIme(self.adb)
        self.recorder = Recorder(self.adb)
        self._register_rotation_watcher()
github AirtestProject / Airtest / tests / test_adb.py View on Github external
def setUpClass(cls):
        devices = ADB().devices(state="device")
        if not devices:
            raise RuntimeError("At lease one adb device required")
        cls.adb = ADB(devices[0][0])
github buffaloleo143 / airtest_runner / mywindowdlg.py View on Github external
def __init__(self, parent=None):
		super(MyWindow, self).__init__(parent)
		self.setupUi(self)
		self.InitListWidget()
		self.InitSignal()
		self.m_ScriptRoot = utils.GetCfgData('scripts_root')
		self.m_ADB = ADB()
		self.RefreshScripts()
		self.RefreshADB()
		self.m_Running = False
github AirtestProject / Airtest / tests / test_adb.py View on Github external
def test_other_adb_server(self):
        adb = ADB(server_addr=("localhost", 5037))
        self.assertIn("1.0.39", adb.version())
github saint228 / DreamMultiDevices / core / MultiAdb.py View on Github external
import threading
import queue
from DreamMultiDevices.core import RunTestCase
from DreamMultiDevices.tools import Config
from airtest.core.api import *
from airtest.core.error import *
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
from airtest.core.android.adb import ADB
import  subprocess
from airtest.utils.apkparser import APK

_print = print
def print(*args, **kwargs):
    _print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), *args, **kwargs)

adb = ADB().adb_path
#同文件内用queue进行线程通信
q = queue.Queue()

'''
MultiAdb类封装了所有与设备有关的方法。
大部分方法都单独写了注释。

'''

class MultiAdb:

    def __init__(self,mdevice=""):
        #获取当前文件的上层路径
        self._parentPath=os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())) + os.path.sep + ".")
        #获取当前项目的根路径
        self._rootPath=os.path.abspath(os.path.dirname(self._parentPath) + os.path.sep + ".")
github saint228 / DreamMultiDevices / tools / Excel.py View on Github external
# -*- coding: utf-8 -*-
__author__ = "无声"
from airtest.core.android.adb import ADB
import xlwings as xw
import os
import time
import json
import traceback
adb = ADB().adb_path

reportpath = os.path.join(os.getcwd(), "Report")
datapath=os.path.join(reportpath, "Data")

#创建一个log_excel用以记录性能数据
def create_log_excel(nowtime,device):
    create_time=time.strftime("%m%d%H%M", nowtime)
    exclefile = datapath+"\\"+create_time+ "_"+ device + "_log.xlsx"
    app = xw.App(visible=True, add_book=False)
    wb = app.books.add()
    sheet = wb.sheets.active
    sheet.range('A1').value = ["Time","TotalMemory(MB)", "AllocatedMemory(MB)","UsedMemory(MB)","FreeMemory(MB)","TotalCPU","AllocatedCPU","FPS","","PNG","PNGAddress"]
    sheet.range('A1:K1').color=205, 197, 191
    if os.path.exists(exclefile):
        raise Exception( "FileHasExisted")
    wb.save(exclefile)
github saint228 / DreamMultiDevices / tools / Init_MiniCap.py View on Github external
__author__ = "无声"


import os
import inspect
import time
from airtest.core.android.adb import ADB
import traceback
from DreamMultiDevices.core.MultiAdb import MultiAdb as Madb
from DreamMultiDevices.tools.Screencap import *

_print = print
def print(*args, **kwargs):
    _print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), *args, **kwargs)

adb = ADB().adb_path

#用来给设备初始化MiniCap的,介绍见 https://blog.csdn.net/saint_228/article/details/92142914
def ini_MiniCap(devices):
    try:
        parent_path = os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())) + os.path.sep + ".")
        root_path = os.path.abspath(os.path.dirname(parent_path) + os.path.sep + ".")
        print("项目目录为{}".format(root_path))
        ABIcommand=adb+" -s {} shell getprop ro.product.cpu.abi".format(devices)
        ABI=os.popen(ABIcommand).read().strip()
        print("ABI为{}".format(ABI))
        AndroidVersion = os.popen(adb + " -s {} shell getprop ro.build.version.sdk".format(devices)).read().strip()
        airtest_minicap_path=os.path.abspath(os.path.dirname(root_path) + os.path.sep + ".")+"\\airtest\\core\\android\\static\\stf_libs"
        airtest_minicapso_path= os.path.abspath(os.path.dirname(root_path) + os.path.sep + ".")+"\\airtest\\core\\android\\static\\stf_libs\\minicap-shared\\aosp\\libs\\"+"android-{}\\{}\\minicap.so".format(AndroidVersion,ABI)
        push_minicap=adb + " -s {} push {}/{}/minicap".format(devices,airtest_minicap_path,ABI) +" /data/local/tmp/"
        push_minicapso = adb + " -s {} push {}".format(devices, airtest_minicapso_path) + " /data/local/tmp/"
        print("推送minicap和minicap.so")