appnium 自动化操控多台设备执行报错:A session is either terminated or not started

添加参数 newCommandTimeout 相当于保活吧 。

def andriod_driver(device_id, port):
    desired_caps = {
        'platformName': 'Android',
        'deviceName':'m3_note',
        'udid': device_id,
        'appPackage': APP_PACKAGE,
        'appActivity': APP_ACTIVITY,
        'unicodeKeyboard': True,
        'resetKeyboard': True,
        'noReset':not APP_RESET,
        'newCommandTimeout':4000 // 单位S
    }
    remote_url = 'http://localhost:' + str(port) + '/wd/hub'
    print(remote_url)
    time.sleep(5)
    driver = webdriver.Remote(remote_url, desired_caps)
    start_add_friend(driver, device_id)
    return driver

你可能感兴趣的:(appnium 自动化操控多台设备执行报错:A session is either terminated or not started)