原创 

python +appium 获取电脑连接的所有手机多线程并发控制

分类:android    308人阅读    IT小君  2019-04-27 20:14
def get_phone_list():
    t_list = []
    devices = list(os.popen('adb devices').readlines())
    for index in range(1, len(devices) - 1):
        desire_caps = dict()
        desire_caps['platformName'] = 'Android'
        desire_caps['noReset'] = True
        desire_caps["simpleIsVisibleCheck"] = True
        item = devices[index]
        deviceId = str(item).split("\t")[0]
        deviceAndroidVersion = list(
            os.popen('adb -s ' + deviceId + ' shell  getprop ro.build.version.release').readlines())
        brand = list(
            os.popen('adb -s ' + deviceId + ' shell  getprop ro.product.brand').readlines())
        model = list(
            os.popen('adb -s ' + deviceId + ' shell  getprop ro.product.model').readlines())

        deviceVersion = str(deviceAndroidVersion[0]).replace("\n", "")
        brand = str(brand[0]).replace("\n", "")
        model = str(model[0]).replace("\n", "")
        desire_caps['platformVersion'] = deviceVersion
        desire_caps['deviceName'] = deviceId
        desire_caps['id'] = brand + '-' + model
        print(brand + '-' + model)
        print(deviceVersion)
        print(deviceId)
        thread = threading.Thread(target=run_one, name=desire_caps['id'], args=(desire_caps,))
        t_list.append(thread)
    return t_list


if __name__ == "__main__":
    t_list = get_phone_list()
    for item in t_list:
        item.start()
    for item in t_list:
        item.join()


支付宝打赏 微信打赏

如果文章对你有帮助,欢迎点击上方按钮打赏作者

 工具推荐 更多»